@base44-preview/vite-plugin 1.0.52-pr.148.ed1fce6 → 1.0.52-pr.150.8afc358
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -7
- package/dist/hidden-source-maps-plugin.d.ts +50 -0
- package/dist/hidden-source-maps-plugin.d.ts.map +1 -0
- package/dist/hidden-source-maps-plugin.js +133 -0
- package/dist/hidden-source-maps-plugin.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/hidden-source-maps-plugin.ts +171 -0
- package/src/index.ts +7 -0
- package/src/utils.ts +6 -1
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ The plugin registers these sub-plugins when running in a sandbox (`MODAL_SANDBOX
|
|
|
47
47
|
4. **html-injections** — Injects sandbox-side scripts into the HTML while serving. Under bundled dev mode its sibling **html-injections-bundled** injects them instead, before the HTML is bundled.
|
|
48
48
|
5. **html-injections-production** — Injects the analytics tracker into production builds.
|
|
49
49
|
|
|
50
|
+
In or out of a sandbox, `base44-hidden-source-maps` joins any build run with `BASE44_HIDDEN_SOURCE_MAPS=1` (see [Hidden source maps](#hidden-source-maps-base44-builds)).
|
|
51
|
+
|
|
50
52
|
Dev and production are told apart by the Vite command (`serve` vs `build`), not by the presence of a dev server in the HTML transform context — bundled dev runs the HTML through the build-shaped transform, where no server is passed.
|
|
51
53
|
|
|
52
54
|
Outside a sandbox, only the core plugin runs (with optional API proxy support via `VITE_BASE44_APP_BASE_URL`).
|
|
@@ -136,6 +138,41 @@ read `ok: true`. That window is already covered server-side by the existing
|
|
|
136
138
|
`dev_server_error_classifier` (install / start failures surface as `409`). This
|
|
137
139
|
endpoint's job is **post-load HMR / compile errors**, not cold-start failures.
|
|
138
140
|
|
|
141
|
+
### Hidden source maps (Base44 builds)
|
|
142
|
+
|
|
143
|
+
A Base44 platform option, set by Base44's build environment rather than by the
|
|
144
|
+
app. When `vite build` runs with
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
BASE44_HIDDEN_SOURCE_MAPS=1
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
the `base44-hidden-source-maps` sub-plugin gives the browser build source maps
|
|
151
|
+
that the platform stores privately and uses to map browser stack traces to the
|
|
152
|
+
app's own files:
|
|
153
|
+
|
|
154
|
+
- **Hidden.** `build.sourcemap: "hidden"`: `.map` files are emitted, but no
|
|
155
|
+
bundle file carries a `sourceMappingURL` comment, so browsers never fetch them.
|
|
156
|
+
- **No source text.** `sourcemapExcludeSources` is set on every output (under
|
|
157
|
+
`build.rollupOptions.output` before Vite 8, `build.rolldownOptions.output` on
|
|
158
|
+
Vite 8), so a map holds file names and positions only. After bundling, any
|
|
159
|
+
`.map` the build emits that still has `sourcesContent` has it removed: a web
|
|
160
|
+
worker's, which Vite bundles separately, or a map from another plugin or a
|
|
161
|
+
future Vite (a CSS map, say). A map that is not valid JSON is reported as a
|
|
162
|
+
warning.
|
|
163
|
+
- **The app's choice wins.** If `build.sourcemap` is already set, by the app's
|
|
164
|
+
config or by another plugin, to any value including `false`, source maps are
|
|
165
|
+
left exactly as configured.
|
|
166
|
+
- **Browser build only.** With Vite environments (6+) only the client
|
|
167
|
+
environment changes; an SSR or Worker build keeps its own config. A Vite 5
|
|
168
|
+
`vite build --ssr` is left alone too.
|
|
169
|
+
- **Build only.** The dev server and `vite preview` are untouched.
|
|
170
|
+
|
|
171
|
+
Like `BASE44_BUILD_STATUS_ENABLED`, the variable is read when the plugin
|
|
172
|
+
assembles its plugin list, so the app's `vite.config.js` does not change. Unset,
|
|
173
|
+
or set to anything other than `1`, the sub-plugin is not added and the build
|
|
174
|
+
output is byte-identical to a build without it.
|
|
175
|
+
|
|
139
176
|
### Route request logs (full-stack apps)
|
|
140
177
|
|
|
141
178
|
Dev-only. While a Nitro server route serves a request that carries
|
|
@@ -214,13 +251,6 @@ npm run build # TypeScript compilation (plugin)
|
|
|
214
251
|
npm run build:bridge # tsup bundle (bridge ES module for browsers)
|
|
215
252
|
```
|
|
216
253
|
|
|
217
|
-
## Testing
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
npm run test:unit # unit tests (vitest)
|
|
221
|
-
npm run validate-exports # checks every path in the package.json export map exists; run after both builds
|
|
222
|
-
```
|
|
223
|
-
|
|
224
254
|
## Server-side static-egress TCP
|
|
225
255
|
|
|
226
256
|
The server-only `base44:runtime` module exports `staticEgress.connect(address,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BuildEnvironmentOptions, Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Hidden source maps for the browser build, for Base44's build environment.
|
|
4
|
+
*
|
|
5
|
+
* `index.ts` adds this plugin only when `BASE44_HIDDEN_SOURCE_MAPS=1`. It sets
|
|
6
|
+
* `build.sourcemap: "hidden"`, so the bundle carries no `sourceMappingURL`
|
|
7
|
+
* comment, and leaves the source text out of the maps. The platform keeps the
|
|
8
|
+
* maps private and uses them to map browser stack traces to the app's files.
|
|
9
|
+
*
|
|
10
|
+
* - Build only (`apply: "build"`): the dev server and `vite preview` never see it.
|
|
11
|
+
* - Browser build only: under Vite's environments (6+) only the client
|
|
12
|
+
* environment changes, so an SSR or Worker build keeps its own config.
|
|
13
|
+
* - The app's choice wins: a `build.sourcemap` already set, `false` included,
|
|
14
|
+
* leaves source maps exactly as configured.
|
|
15
|
+
*
|
|
16
|
+
* `sourcemapExcludeSources` covers the bundle's own chunks. Vite bundles web
|
|
17
|
+
* workers separately with only some of those output options, so after bundling
|
|
18
|
+
* any `.map` that still holds source text has it removed: a worker's, or one
|
|
19
|
+
* from any other plugin or future Vite.
|
|
20
|
+
*/
|
|
21
|
+
type BundlerOutputOptions = Record<string, unknown>;
|
|
22
|
+
type BundlerOptions = {
|
|
23
|
+
output?: BundlerOutputOptions | BundlerOutputOptions[] | undefined;
|
|
24
|
+
} & Record<string, unknown>;
|
|
25
|
+
type BuildOptions = BuildEnvironmentOptions & {
|
|
26
|
+
rolldownOptions?: BundlerOptions;
|
|
27
|
+
};
|
|
28
|
+
export interface HiddenSourceMapsOptions {
|
|
29
|
+
/** Whether bundler options live under `rolldownOptions`. Defaults to the installed Vite's. */
|
|
30
|
+
rolldown?: boolean;
|
|
31
|
+
/** Whether Vite has environments (`configEnvironment`). Defaults to the installed Vite's. */
|
|
32
|
+
environments?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The build options with hidden, sourceless maps, or `null` when the app chose
|
|
36
|
+
* its own `sourcemap`. Builds new objects all the way down: Vite shares nested
|
|
37
|
+
* build objects between the top-level config and every environment, so editing
|
|
38
|
+
* one in place would leak into the SSR build.
|
|
39
|
+
*/
|
|
40
|
+
export declare function withHiddenSourceMaps(build: BuildOptions | undefined, { rolldown }: {
|
|
41
|
+
rolldown: boolean;
|
|
42
|
+
}): BuildOptions | null;
|
|
43
|
+
/**
|
|
44
|
+
* A source map's JSON without its source text, or `null` if it has none.
|
|
45
|
+
* Throws if `map` is not JSON, so the caller can say a map went out unexamined.
|
|
46
|
+
*/
|
|
47
|
+
export declare function withoutSourcesContent(map: string): string | null;
|
|
48
|
+
export declare function hiddenSourceMapsPlugin({ rolldown, environments, }?: HiddenSourceMapsOptions): Plugin;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=hidden-source-maps-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hidden-source-maps-plugin.d.ts","sourceRoot":"","sources":["../src/hidden-source-maps-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG5D;;;;;;;;;;;;;;;;;;GAkBG;AAEH,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpD,KAAK,cAAc,GAAG;IAAE,MAAM,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,SAAS,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvH,KAAK,YAAY,GAAG,uBAAuB,GAAG;IAE5C,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6FAA6F;IAC7F,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAOD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAClC,YAAY,GAAG,IAAI,CAmCrB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOhE;AAED,wBAAgB,sBAAsB,CAAC,EACrC,QAAyB,EACzB,YAA6B,GAC9B,GAAE,uBAA4B,GAAG,MAAM,CAkEvC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { isVite6OrLater, isVite8OrLater } from "./utils.js";
|
|
2
|
+
const excludeSources = (output) => ({
|
|
3
|
+
...output,
|
|
4
|
+
sourcemapExcludeSources: true,
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* The build options with hidden, sourceless maps, or `null` when the app chose
|
|
8
|
+
* its own `sourcemap`. Builds new objects all the way down: Vite shares nested
|
|
9
|
+
* build objects between the top-level config and every environment, so editing
|
|
10
|
+
* one in place would leak into the SSR build.
|
|
11
|
+
*/
|
|
12
|
+
export function withHiddenSourceMaps(build, { rolldown }) {
|
|
13
|
+
if (build?.sourcemap !== undefined)
|
|
14
|
+
return null;
|
|
15
|
+
const key = rolldown ? "rolldownOptions" : "rollupOptions";
|
|
16
|
+
// Vite 8 reads `rolldownOptions`, and aliases `rollupOptions` to it.
|
|
17
|
+
const current = ((rolldown ? build?.rolldownOptions ?? build?.rollupOptions : build?.rollupOptions) ?? {});
|
|
18
|
+
const { output } = current;
|
|
19
|
+
const next = {
|
|
20
|
+
...build,
|
|
21
|
+
sourcemap: "hidden",
|
|
22
|
+
[key]: {
|
|
23
|
+
...current,
|
|
24
|
+
// An app may build several outputs; each one leaves its sources out.
|
|
25
|
+
output: Array.isArray(output) ? output.map(excludeSources) : excludeSources(output),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
if (rolldown) {
|
|
29
|
+
// Spreading copied the alias as a plain, stale value. Put back the alias
|
|
30
|
+
// Vite 8 itself sets up, so later readers of `rollupOptions` see the same
|
|
31
|
+
// object Vite reads.
|
|
32
|
+
delete next.rollupOptions;
|
|
33
|
+
Object.defineProperty(next, "rollupOptions", {
|
|
34
|
+
get: () => next.rolldownOptions,
|
|
35
|
+
set: (value) => {
|
|
36
|
+
next.rolldownOptions = value;
|
|
37
|
+
},
|
|
38
|
+
configurable: true,
|
|
39
|
+
enumerable: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return next;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A source map's JSON without its source text, or `null` if it has none.
|
|
46
|
+
* Throws if `map` is not JSON, so the caller can say a map went out unexamined.
|
|
47
|
+
*/
|
|
48
|
+
export function withoutSourcesContent(map) {
|
|
49
|
+
// Most maps already lack source text; skip parsing what may be megabytes.
|
|
50
|
+
if (!map.includes('"sourcesContent"'))
|
|
51
|
+
return null;
|
|
52
|
+
const parsed = JSON.parse(map);
|
|
53
|
+
if (!parsed || typeof parsed !== "object" || !("sourcesContent" in parsed))
|
|
54
|
+
return null;
|
|
55
|
+
delete parsed.sourcesContent;
|
|
56
|
+
return JSON.stringify(parsed);
|
|
57
|
+
}
|
|
58
|
+
export function hiddenSourceMapsPlugin({ rolldown = isVite8OrLater, environments = isVite6OrLater, } = {}) {
|
|
59
|
+
// The builds this plugin gave hidden maps: environment names on Vite 6+, or
|
|
60
|
+
// the one browser build (`true`) on Vite 5.
|
|
61
|
+
const changed = new Set();
|
|
62
|
+
return {
|
|
63
|
+
name: "base44-hidden-source-maps",
|
|
64
|
+
apply: "build",
|
|
65
|
+
// Run after other plugins' config hooks, so a source-map choice made by a
|
|
66
|
+
// framework plugin counts as the app's own.
|
|
67
|
+
config: {
|
|
68
|
+
order: "post",
|
|
69
|
+
handler(config, env) {
|
|
70
|
+
changed.clear();
|
|
71
|
+
// Vite 6+ is handled per environment below: the top-level build
|
|
72
|
+
// options feed the SSR environment too.
|
|
73
|
+
if (environments)
|
|
74
|
+
return;
|
|
75
|
+
// Vite 5 runs an SSR build as its own `vite build --ssr`.
|
|
76
|
+
if (config.build?.ssr || env.isSsrBuild)
|
|
77
|
+
return;
|
|
78
|
+
const build = withHiddenSourceMaps(config.build, { rolldown });
|
|
79
|
+
if (build) {
|
|
80
|
+
config.build = build;
|
|
81
|
+
changed.add(true);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
configEnvironment: {
|
|
86
|
+
order: "post",
|
|
87
|
+
handler(name, config) {
|
|
88
|
+
if (!environments)
|
|
89
|
+
return;
|
|
90
|
+
const consumer = config.consumer ?? (name === "client" ? "client" : "server");
|
|
91
|
+
if (consumer !== "client")
|
|
92
|
+
return;
|
|
93
|
+
const build = withHiddenSourceMaps(config.build, { rolldown });
|
|
94
|
+
// Assigned rather than returned: Vite merges a returned config into the
|
|
95
|
+
// existing one, which would append to an `output` array instead of
|
|
96
|
+
// updating each entry.
|
|
97
|
+
if (build) {
|
|
98
|
+
config.build = build;
|
|
99
|
+
changed.add(name);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
generateBundle: {
|
|
104
|
+
// "post" so Vite's worker plugin has already added each worker's chunk
|
|
105
|
+
// and map to this bundle: it emits them from its own generateBundle.
|
|
106
|
+
order: "post",
|
|
107
|
+
handler(_options, bundle) {
|
|
108
|
+
if (changed.size === 0)
|
|
109
|
+
return;
|
|
110
|
+
// Only builds this plugin changed. A build whose environment is unknown
|
|
111
|
+
// is stripped rather than skipped: leaving source text in is the
|
|
112
|
+
// failure this step exists to prevent.
|
|
113
|
+
const name = this.environment?.name;
|
|
114
|
+
if (environments && name !== undefined && !changed.has(name))
|
|
115
|
+
return;
|
|
116
|
+
for (const file of Object.values(bundle)) {
|
|
117
|
+
if (file.type !== "asset" || !file.fileName.endsWith(".map"))
|
|
118
|
+
continue;
|
|
119
|
+
const text = typeof file.source === "string" ? file.source : new TextDecoder().decode(file.source);
|
|
120
|
+
try {
|
|
121
|
+
const stripped = withoutSourcesContent(text);
|
|
122
|
+
if (stripped !== null)
|
|
123
|
+
file.source = stripped;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
this.warn(`${file.fileName} is not valid JSON, so its source text could not be removed.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=hidden-source-maps-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hidden-source-maps-plugin.js","sourceRoot":"","sources":["../src/hidden-source-maps-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAoC5D,MAAM,cAAc,GAAG,CAAC,MAAwC,EAAwB,EAAE,CAAC,CAAC;IAC1F,GAAG,MAAM;IACT,uBAAuB,EAAE,IAAI;CAC9B,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAA+B,EAC/B,EAAE,QAAQ,EAAyB;IAEnC,IAAI,KAAK,EAAE,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEhD,MAAM,GAAG,GAAG,QAAQ,CA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Q,KAAK,IAAI;4BAAE,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;oBAChD,CAAC;oBAAC,MAAM,CAAC;wBACP,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,8DAA8D,CAAC,CAAC;oBAC5F,CAAC;gBACH,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAY/C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAmBlD,eAAO,MAAM,uBAAuB,UAWnC,CAAC;AAeF,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,GAAE;IACJ,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,iBAqQP"}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { base44RuntimePlugin } from "./base44-runtime-plugin.js";
|
|
|
9
9
|
import { workerdCompatPlugin } from "./workerd-compat-plugin.js";
|
|
10
10
|
import { privateDataSourcesPlugin } from "./private-data-sources-plugin.js";
|
|
11
11
|
import { routeRequestLogPlugin } from "./route-request-log/vite-plugin.js";
|
|
12
|
+
import { hiddenSourceMapsPlugin } from "./hidden-source-maps-plugin.js";
|
|
12
13
|
const PLATFORM_API_PROXY_PATH = "^/api/(apps|app-logs)([/?]|$)";
|
|
13
14
|
const isRunningInSandbox = !!process.env.MODAL_SANDBOX_ID;
|
|
14
15
|
// Both optimizer spellings mean the same thing here: treat .js files as JSX,
|
|
@@ -241,6 +242,12 @@ export default function vitePlugin(opts = {}) {
|
|
|
241
242
|
// because Nitro runs dev routes in a worker whose console the Vite process
|
|
242
243
|
// never sees. Inert for apps without Nitro and for requests without the id.
|
|
243
244
|
routeRequestLogPlugin(),
|
|
245
|
+
// Base44's build environment sets BASE44_HIDDEN_SOURCE_MAPS=1 to get private
|
|
246
|
+
// source maps for the browser build. Gated here, like build-status, so an
|
|
247
|
+
// unset flag leaves the pipeline and the build output exactly as before.
|
|
248
|
+
...(process.env.BASE44_HIDDEN_SOURCE_MAPS === "1"
|
|
249
|
+
? [hiddenSourceMapsPlugin()]
|
|
250
|
+
: []),
|
|
244
251
|
];
|
|
245
252
|
}
|
|
246
253
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EA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AA4E;QAC5E,qBAAqB,EAAE;QACvB,6EAA6E;QAC7E,0EAA0E;QAC1E,yEAAyE;QACzE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,KAAK,GAAG;YAC/C,CAAC,CAAC,CAAC,sBAAsB,EAAE,CAAC;YAC5B,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc,SAAiB,CAAC;AAI7C,eAAO,MAAM,cAAc,SAAiB,CAAC;AAc7C,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAAE,EAClB,IAAI,EAAE,MAAM,GACX,MAAM,EAAE,CAmBV"}
|
package/dist/utils.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from "fs";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { version as viteVersion } from "vite";
|
|
4
|
+
const viteMajor = Number(viteVersion.split(".")[0]);
|
|
5
|
+
// Vite 6 added environments (`environments`, `configEnvironment`).
|
|
6
|
+
export const isVite6OrLater = viteMajor >= 6;
|
|
4
7
|
// Vite 8 pre-bundles deps with Rolldown instead of esbuild and deprecates
|
|
5
8
|
// `optimizeDeps.esbuildOptions`.
|
|
6
|
-
export const isVite8OrLater =
|
|
9
|
+
export const isVite8OrLater = viteMajor >= 8;
|
|
7
10
|
/**
|
|
8
11
|
* The package that owns an optimizeDeps entry. Deep entries like
|
|
9
12
|
* `react-dom/client` are separate entries to Vite's optimizer but are declared
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","source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e,CAAC,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG;YACd,GAAG,WAAW,CAAC,YAAY;YAC3B,GAAG,WAAW,CAAC,eAAe;YAC9B,GAAG,WAAW,CAAC,gBAAgB;SAChC,CAAC;QAEF,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { BuildEnvironmentOptions, Plugin } from "vite";
|
|
2
|
+
import { isVite6OrLater, isVite8OrLater } from "./utils.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hidden source maps for the browser build, for Base44's build environment.
|
|
6
|
+
*
|
|
7
|
+
* `index.ts` adds this plugin only when `BASE44_HIDDEN_SOURCE_MAPS=1`. It sets
|
|
8
|
+
* `build.sourcemap: "hidden"`, so the bundle carries no `sourceMappingURL`
|
|
9
|
+
* comment, and leaves the source text out of the maps. The platform keeps the
|
|
10
|
+
* maps private and uses them to map browser stack traces to the app's files.
|
|
11
|
+
*
|
|
12
|
+
* - Build only (`apply: "build"`): the dev server and `vite preview` never see it.
|
|
13
|
+
* - Browser build only: under Vite's environments (6+) only the client
|
|
14
|
+
* environment changes, so an SSR or Worker build keeps its own config.
|
|
15
|
+
* - The app's choice wins: a `build.sourcemap` already set, `false` included,
|
|
16
|
+
* leaves source maps exactly as configured.
|
|
17
|
+
*
|
|
18
|
+
* `sourcemapExcludeSources` covers the bundle's own chunks. Vite bundles web
|
|
19
|
+
* workers separately with only some of those output options, so after bundling
|
|
20
|
+
* any `.map` that still holds source text has it removed: a worker's, or one
|
|
21
|
+
* from any other plugin or future Vite.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
type BundlerOutputOptions = Record<string, unknown>;
|
|
25
|
+
type BundlerOptions = { output?: BundlerOutputOptions | BundlerOutputOptions[] | undefined } & Record<string, unknown>;
|
|
26
|
+
type BuildOptions = BuildEnvironmentOptions & {
|
|
27
|
+
// Vite 8's spelling. Vite 7's types do not know it.
|
|
28
|
+
rolldownOptions?: BundlerOptions;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface HiddenSourceMapsOptions {
|
|
32
|
+
/** Whether bundler options live under `rolldownOptions`. Defaults to the installed Vite's. */
|
|
33
|
+
rolldown?: boolean;
|
|
34
|
+
/** Whether Vite has environments (`configEnvironment`). Defaults to the installed Vite's. */
|
|
35
|
+
environments?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const excludeSources = (output: BundlerOutputOptions | undefined): BundlerOutputOptions => ({
|
|
39
|
+
...output,
|
|
40
|
+
sourcemapExcludeSources: true,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The build options with hidden, sourceless maps, or `null` when the app chose
|
|
45
|
+
* its own `sourcemap`. Builds new objects all the way down: Vite shares nested
|
|
46
|
+
* build objects between the top-level config and every environment, so editing
|
|
47
|
+
* one in place would leak into the SSR build.
|
|
48
|
+
*/
|
|
49
|
+
export function withHiddenSourceMaps(
|
|
50
|
+
build: BuildOptions | undefined,
|
|
51
|
+
{ rolldown }: { rolldown: boolean }
|
|
52
|
+
): BuildOptions | null {
|
|
53
|
+
if (build?.sourcemap !== undefined) return null;
|
|
54
|
+
|
|
55
|
+
const key = rolldown ? "rolldownOptions" : "rollupOptions";
|
|
56
|
+
// Vite 8 reads `rolldownOptions`, and aliases `rollupOptions` to it.
|
|
57
|
+
const current = (
|
|
58
|
+
(rolldown ? build?.rolldownOptions ?? build?.rollupOptions : build?.rollupOptions) ?? {}
|
|
59
|
+
) as BundlerOptions;
|
|
60
|
+
const { output } = current;
|
|
61
|
+
|
|
62
|
+
const next = {
|
|
63
|
+
...build,
|
|
64
|
+
sourcemap: "hidden",
|
|
65
|
+
[key]: {
|
|
66
|
+
...current,
|
|
67
|
+
// An app may build several outputs; each one leaves its sources out.
|
|
68
|
+
output: Array.isArray(output) ? output.map(excludeSources) : excludeSources(output),
|
|
69
|
+
},
|
|
70
|
+
} as BuildOptions;
|
|
71
|
+
|
|
72
|
+
if (rolldown) {
|
|
73
|
+
// Spreading copied the alias as a plain, stale value. Put back the alias
|
|
74
|
+
// Vite 8 itself sets up, so later readers of `rollupOptions` see the same
|
|
75
|
+
// object Vite reads.
|
|
76
|
+
delete next.rollupOptions;
|
|
77
|
+
Object.defineProperty(next, "rollupOptions", {
|
|
78
|
+
get: () => next.rolldownOptions,
|
|
79
|
+
set: (value) => {
|
|
80
|
+
next.rolldownOptions = value;
|
|
81
|
+
},
|
|
82
|
+
configurable: true,
|
|
83
|
+
enumerable: true,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return next;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A source map's JSON without its source text, or `null` if it has none.
|
|
91
|
+
* Throws if `map` is not JSON, so the caller can say a map went out unexamined.
|
|
92
|
+
*/
|
|
93
|
+
export function withoutSourcesContent(map: string): string | null {
|
|
94
|
+
// Most maps already lack source text; skip parsing what may be megabytes.
|
|
95
|
+
if (!map.includes('"sourcesContent"')) return null;
|
|
96
|
+
const parsed = JSON.parse(map);
|
|
97
|
+
if (!parsed || typeof parsed !== "object" || !("sourcesContent" in parsed)) return null;
|
|
98
|
+
delete parsed.sourcesContent;
|
|
99
|
+
return JSON.stringify(parsed);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function hiddenSourceMapsPlugin({
|
|
103
|
+
rolldown = isVite8OrLater,
|
|
104
|
+
environments = isVite6OrLater,
|
|
105
|
+
}: HiddenSourceMapsOptions = {}): Plugin {
|
|
106
|
+
// The builds this plugin gave hidden maps: environment names on Vite 6+, or
|
|
107
|
+
// the one browser build (`true`) on Vite 5.
|
|
108
|
+
const changed = new Set<string | true>();
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
name: "base44-hidden-source-maps",
|
|
112
|
+
apply: "build",
|
|
113
|
+
// Run after other plugins' config hooks, so a source-map choice made by a
|
|
114
|
+
// framework plugin counts as the app's own.
|
|
115
|
+
config: {
|
|
116
|
+
order: "post",
|
|
117
|
+
handler(config, env) {
|
|
118
|
+
changed.clear();
|
|
119
|
+
// Vite 6+ is handled per environment below: the top-level build
|
|
120
|
+
// options feed the SSR environment too.
|
|
121
|
+
if (environments) return;
|
|
122
|
+
// Vite 5 runs an SSR build as its own `vite build --ssr`.
|
|
123
|
+
if (config.build?.ssr || env.isSsrBuild) return;
|
|
124
|
+
const build = withHiddenSourceMaps(config.build, { rolldown });
|
|
125
|
+
if (build) {
|
|
126
|
+
config.build = build;
|
|
127
|
+
changed.add(true);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
configEnvironment: {
|
|
132
|
+
order: "post",
|
|
133
|
+
handler(name, config) {
|
|
134
|
+
if (!environments) return;
|
|
135
|
+
const consumer = config.consumer ?? (name === "client" ? "client" : "server");
|
|
136
|
+
if (consumer !== "client") return;
|
|
137
|
+
const build = withHiddenSourceMaps(config.build, { rolldown });
|
|
138
|
+
// Assigned rather than returned: Vite merges a returned config into the
|
|
139
|
+
// existing one, which would append to an `output` array instead of
|
|
140
|
+
// updating each entry.
|
|
141
|
+
if (build) {
|
|
142
|
+
config.build = build;
|
|
143
|
+
changed.add(name);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
generateBundle: {
|
|
148
|
+
// "post" so Vite's worker plugin has already added each worker's chunk
|
|
149
|
+
// and map to this bundle: it emits them from its own generateBundle.
|
|
150
|
+
order: "post",
|
|
151
|
+
handler(_options, bundle) {
|
|
152
|
+
if (changed.size === 0) return;
|
|
153
|
+
// Only builds this plugin changed. A build whose environment is unknown
|
|
154
|
+
// is stripped rather than skipped: leaving source text in is the
|
|
155
|
+
// failure this step exists to prevent.
|
|
156
|
+
const name = (this as { environment?: { name?: string } }).environment?.name;
|
|
157
|
+
if (environments && name !== undefined && !changed.has(name)) return;
|
|
158
|
+
for (const file of Object.values(bundle)) {
|
|
159
|
+
if (file.type !== "asset" || !file.fileName.endsWith(".map")) continue;
|
|
160
|
+
const text = typeof file.source === "string" ? file.source : new TextDecoder().decode(file.source);
|
|
161
|
+
try {
|
|
162
|
+
const stripped = withoutSourcesContent(text);
|
|
163
|
+
if (stripped !== null) file.source = stripped;
|
|
164
|
+
} catch {
|
|
165
|
+
this.warn(`${file.fileName} is not valid JSON, so its source text could not be removed.`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { base44RuntimePlugin } from "./base44-runtime-plugin.js";
|
|
|
10
10
|
import { workerdCompatPlugin } from "./workerd-compat-plugin.js";
|
|
11
11
|
import { privateDataSourcesPlugin } from "./private-data-sources-plugin.js";
|
|
12
12
|
import { routeRequestLogPlugin } from "./route-request-log/vite-plugin.js";
|
|
13
|
+
import { hiddenSourceMapsPlugin } from "./hidden-source-maps-plugin.js";
|
|
13
14
|
export type { DocumentScript } from "./consts.js";
|
|
14
15
|
|
|
15
16
|
const PLATFORM_API_PROXY_PATH = "^/api/(apps|app-logs)([/?]|$)";
|
|
@@ -316,5 +317,11 @@ export default function vitePlugin(
|
|
|
316
317
|
// because Nitro runs dev routes in a worker whose console the Vite process
|
|
317
318
|
// never sees. Inert for apps without Nitro and for requests without the id.
|
|
318
319
|
routeRequestLogPlugin(),
|
|
320
|
+
// Base44's build environment sets BASE44_HIDDEN_SOURCE_MAPS=1 to get private
|
|
321
|
+
// source maps for the browser build. Gated here, like build-status, so an
|
|
322
|
+
// unset flag leaves the pipeline and the build output exactly as before.
|
|
323
|
+
...(process.env.BASE44_HIDDEN_SOURCE_MAPS === "1"
|
|
324
|
+
? [hiddenSourceMapsPlugin()]
|
|
325
|
+
: []),
|
|
319
326
|
];
|
|
320
327
|
}
|
package/src/utils.ts
CHANGED
|
@@ -2,9 +2,14 @@ import { readFileSync, existsSync } from "fs";
|
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { version as viteVersion } from "vite";
|
|
4
4
|
|
|
5
|
+
const viteMajor = Number(viteVersion.split(".")[0]);
|
|
6
|
+
|
|
7
|
+
// Vite 6 added environments (`environments`, `configEnvironment`).
|
|
8
|
+
export const isVite6OrLater = viteMajor >= 6;
|
|
9
|
+
|
|
5
10
|
// Vite 8 pre-bundles deps with Rolldown instead of esbuild and deprecates
|
|
6
11
|
// `optimizeDeps.esbuildOptions`.
|
|
7
|
-
export const isVite8OrLater =
|
|
12
|
+
export const isVite8OrLater = viteMajor >= 8;
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* The package that owns an optimizeDeps entry. Deep entries like
|