@base44-preview/vite-plugin 1.0.52-pr.150.8afc358 → 1.0.52-pr.150.bd79020
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 +3 -5
- package/dist/hidden-source-maps-plugin.d.ts +2 -6
- package/dist/hidden-source-maps-plugin.d.ts.map +1 -1
- package/dist/hidden-source-maps-plugin.js +14 -28
- package/dist/hidden-source-maps-plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/hidden-source-maps-plugin.ts +15 -26
package/README.md
CHANGED
|
@@ -155,11 +155,9 @@ app's own files:
|
|
|
155
155
|
bundle file carries a `sourceMappingURL` comment, so browsers never fetch them.
|
|
156
156
|
- **No source text.** `sourcemapExcludeSources` is set on every output (under
|
|
157
157
|
`build.rollupOptions.output` before Vite 8, `build.rolldownOptions.output` on
|
|
158
|
-
Vite 8), so a map holds file names and positions only.
|
|
159
|
-
`.map`
|
|
160
|
-
worker's
|
|
161
|
-
future Vite (a CSS map, say). A map that is not valid JSON is reported as a
|
|
162
|
-
warning.
|
|
158
|
+
Vite 8), so a map holds file names and positions only. Vite bundles web
|
|
159
|
+
workers separately, so any emitted `.map` that still has `sourcesContent`
|
|
160
|
+
(a worker's) has it removed after bundling. Vite emits no CSS maps in builds.
|
|
163
161
|
- **The app's choice wins.** If `build.sourcemap` is already set, by the app's
|
|
164
162
|
config or by another plugin, to any value including `false`, source maps are
|
|
165
163
|
left exactly as configured.
|
|
@@ -15,8 +15,7 @@ import type { BuildEnvironmentOptions, Plugin } from "vite";
|
|
|
15
15
|
*
|
|
16
16
|
* `sourcemapExcludeSources` covers the bundle's own chunks. Vite bundles web
|
|
17
17
|
* workers separately with only some of those output options, so after bundling
|
|
18
|
-
* any `.map` that still holds source text has it removed
|
|
19
|
-
* from any other plugin or future Vite.
|
|
18
|
+
* any `.map` that still holds source text has it removed.
|
|
20
19
|
*/
|
|
21
20
|
type BundlerOutputOptions = Record<string, unknown>;
|
|
22
21
|
type BundlerOptions = {
|
|
@@ -40,10 +39,7 @@ export interface HiddenSourceMapsOptions {
|
|
|
40
39
|
export declare function withHiddenSourceMaps(build: BuildOptions | undefined, { rolldown }: {
|
|
41
40
|
rolldown: boolean;
|
|
42
41
|
}): 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
|
-
*/
|
|
42
|
+
/** A source map's JSON without its source text, or `null` if it has none or is not a map. */
|
|
47
43
|
export declare function withoutSourcesContent(map: string): string | null;
|
|
48
44
|
export declare function hiddenSourceMapsPlugin({ rolldown, environments, }?: HiddenSourceMapsOptions): Plugin;
|
|
49
45
|
export {};
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;GAiBG;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,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED,wBAAgB,sBAAsB,CAAC,EACrC,QAAyB,EACzB,YAA6B,GAC9B,GAAE,uBAA4B,GAAG,MAAM,CAyDvC"}
|
|
@@ -41,19 +41,18 @@ export function withHiddenSourceMaps(build, { rolldown }) {
|
|
|
41
41
|
}
|
|
42
42
|
return next;
|
|
43
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
|
-
*/
|
|
44
|
+
/** A source map's JSON without its source text, or `null` if it has none or is not a map. */
|
|
48
45
|
export function withoutSourcesContent(map) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
try {
|
|
47
|
+
const parsed = JSON.parse(map);
|
|
48
|
+
if (!parsed || typeof parsed !== "object" || !("sourcesContent" in parsed))
|
|
49
|
+
return null;
|
|
50
|
+
delete parsed.sourcesContent;
|
|
51
|
+
return JSON.stringify(parsed);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
54
|
return null;
|
|
55
|
-
|
|
56
|
-
return JSON.stringify(parsed);
|
|
55
|
+
}
|
|
57
56
|
}
|
|
58
57
|
export function hiddenSourceMapsPlugin({ rolldown = isVite8OrLater, environments = isVite6OrLater, } = {}) {
|
|
59
58
|
// The builds this plugin gave hidden maps: environment names on Vite 6+, or
|
|
@@ -101,30 +100,17 @@ export function hiddenSourceMapsPlugin({ rolldown = isVite8OrLater, environments
|
|
|
101
100
|
},
|
|
102
101
|
},
|
|
103
102
|
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
103
|
order: "post",
|
|
107
104
|
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
105
|
const name = this.environment?.name;
|
|
114
|
-
if (environments
|
|
106
|
+
if (!changed.has(environments ? name ?? "client" : true))
|
|
115
107
|
return;
|
|
116
108
|
for (const file of Object.values(bundle)) {
|
|
117
109
|
if (file.type !== "asset" || !file.fileName.endsWith(".map"))
|
|
118
110
|
continue;
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
}
|
|
111
|
+
const stripped = withoutSourcesContent(typeof file.source === "string" ? file.source : new TextDecoder().decode(file.source));
|
|
112
|
+
if (stripped !== null)
|
|
113
|
+
file.source = stripped;
|
|
128
114
|
}
|
|
129
115
|
},
|
|
130
116
|
},
|
|
@@ -1 +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;
|
|
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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Q,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CACtF,CAAC;oBACF,IAAI,QAAQ,KAAK,IAAI;wBAAE,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;gBAChD,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -17,8 +17,7 @@ import { isVite6OrLater, isVite8OrLater } from "./utils.js";
|
|
|
17
17
|
*
|
|
18
18
|
* `sourcemapExcludeSources` covers the bundle's own chunks. Vite bundles web
|
|
19
19
|
* workers separately with only some of those output options, so after bundling
|
|
20
|
-
* any `.map` that still holds source text has it removed
|
|
21
|
-
* from any other plugin or future Vite.
|
|
20
|
+
* any `.map` that still holds source text has it removed.
|
|
22
21
|
*/
|
|
23
22
|
|
|
24
23
|
type BundlerOutputOptions = Record<string, unknown>;
|
|
@@ -86,17 +85,16 @@ export function withHiddenSourceMaps(
|
|
|
86
85
|
return next;
|
|
87
86
|
}
|
|
88
87
|
|
|
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
|
-
*/
|
|
88
|
+
/** A source map's JSON without its source text, or `null` if it has none or is not a map. */
|
|
93
89
|
export function withoutSourcesContent(map: string): string | null {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
try {
|
|
91
|
+
const parsed = JSON.parse(map);
|
|
92
|
+
if (!parsed || typeof parsed !== "object" || !("sourcesContent" in parsed)) return null;
|
|
93
|
+
delete parsed.sourcesContent;
|
|
94
|
+
return JSON.stringify(parsed);
|
|
95
|
+
} catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
export function hiddenSourceMapsPlugin({
|
|
@@ -145,25 +143,16 @@ export function hiddenSourceMapsPlugin({
|
|
|
145
143
|
},
|
|
146
144
|
},
|
|
147
145
|
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
146
|
order: "post",
|
|
151
147
|
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
148
|
const name = (this as { environment?: { name?: string } }).environment?.name;
|
|
157
|
-
if (environments
|
|
149
|
+
if (!changed.has(environments ? name ?? "client" : true)) return;
|
|
158
150
|
for (const file of Object.values(bundle)) {
|
|
159
151
|
if (file.type !== "asset" || !file.fileName.endsWith(".map")) continue;
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} catch {
|
|
165
|
-
this.warn(`${file.fileName} is not valid JSON, so its source text could not be removed.`);
|
|
166
|
-
}
|
|
152
|
+
const stripped = withoutSourcesContent(
|
|
153
|
+
typeof file.source === "string" ? file.source : new TextDecoder().decode(file.source)
|
|
154
|
+
);
|
|
155
|
+
if (stripped !== null) file.source = stripped;
|
|
167
156
|
}
|
|
168
157
|
},
|
|
169
158
|
},
|