@vitejs/plugin-legacy 2.0.1 → 2.1.0-beta.0
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/dist/index.cjs +25 -46
- package/dist/index.mjs +25 -46
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -115,14 +115,20 @@ function viteLegacyPlugin(options = {}) {
|
|
|
115
115
|
}
|
|
116
116
|
const legacyConfigPlugin = {
|
|
117
117
|
name: "vite:legacy-config",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
config(config2, env) {
|
|
119
|
+
if (env.command === "build") {
|
|
120
|
+
if (!config2.build) {
|
|
121
|
+
config2.build = {};
|
|
122
|
+
}
|
|
123
|
+
if (!config2.build.cssTarget) {
|
|
124
|
+
config2.build.cssTarget = "chrome61";
|
|
125
|
+
}
|
|
125
126
|
}
|
|
127
|
+
return {
|
|
128
|
+
define: {
|
|
129
|
+
"import.meta.env.LEGACY": env.command === "serve" || config2.build?.ssr ? false : legacyEnvVarMarker
|
|
130
|
+
}
|
|
131
|
+
};
|
|
126
132
|
}
|
|
127
133
|
};
|
|
128
134
|
const legacyGenerateBundlePlugin = {
|
|
@@ -141,6 +147,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
141
147
|
modernPolyfills
|
|
142
148
|
);
|
|
143
149
|
await buildPolyfillChunk(
|
|
150
|
+
config.mode,
|
|
144
151
|
modernPolyfills,
|
|
145
152
|
bundle,
|
|
146
153
|
facadeToModernPolyfillMap,
|
|
@@ -165,6 +172,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
165
172
|
legacyPolyfills
|
|
166
173
|
);
|
|
167
174
|
await buildPolyfillChunk(
|
|
175
|
+
config.mode,
|
|
168
176
|
legacyPolyfills,
|
|
169
177
|
bundle,
|
|
170
178
|
facadeToLegacyPolyfillMap,
|
|
@@ -409,34 +417,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
409
417
|
}
|
|
410
418
|
}
|
|
411
419
|
};
|
|
412
|
-
|
|
413
|
-
const legacyEnvPlugin = {
|
|
414
|
-
name: "vite:legacy-env",
|
|
415
|
-
config(config2, env) {
|
|
416
|
-
if (env) {
|
|
417
|
-
return {
|
|
418
|
-
define: {
|
|
419
|
-
"import.meta.env.LEGACY": env.command === "serve" || config2.build?.ssr ? false : legacyEnvVarMarker
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
} else {
|
|
423
|
-
envInjectionFailed = true;
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
configResolved(config2) {
|
|
427
|
-
if (envInjectionFailed) {
|
|
428
|
-
config2.logger.warn(
|
|
429
|
-
`[@vitejs/plugin-legacy] import.meta.env.LEGACY was not injected due to incompatible vite version (requires vite@^2.0.0-beta.69).`
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
return [
|
|
435
|
-
legacyConfigPlugin,
|
|
436
|
-
legacyGenerateBundlePlugin,
|
|
437
|
-
legacyPostPlugin,
|
|
438
|
-
legacyEnvPlugin
|
|
439
|
-
];
|
|
420
|
+
return [legacyConfigPlugin, legacyGenerateBundlePlugin, legacyPostPlugin];
|
|
440
421
|
}
|
|
441
422
|
async function detectPolyfills(code, targets, list) {
|
|
442
423
|
const babel2 = await loadBabel();
|
|
@@ -478,17 +459,17 @@ function createBabelPresetEnvOptions(targets, {
|
|
|
478
459
|
ignoreBrowserslistConfig
|
|
479
460
|
};
|
|
480
461
|
}
|
|
481
|
-
async function buildPolyfillChunk(imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS) {
|
|
462
|
+
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS) {
|
|
482
463
|
let { minify, assetsDir } = buildOptions;
|
|
483
464
|
minify = minify ? "terser" : false;
|
|
484
465
|
const res = await vite.build({
|
|
466
|
+
mode,
|
|
485
467
|
root: path__default.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)))),
|
|
486
468
|
configFile: false,
|
|
487
469
|
logLevel: "error",
|
|
488
470
|
plugins: [polyfillsPlugin(imports, excludeSystemJS)],
|
|
489
471
|
build: {
|
|
490
472
|
write: false,
|
|
491
|
-
target: "es5",
|
|
492
473
|
minify,
|
|
493
474
|
assetsDir,
|
|
494
475
|
rollupOptions: {
|
|
@@ -497,10 +478,15 @@ async function buildPolyfillChunk(imports, bundle, facadeToChunkMap, buildOption
|
|
|
497
478
|
},
|
|
498
479
|
output: {
|
|
499
480
|
format,
|
|
500
|
-
entryFileNames: rollupOutputOptions.entryFileNames
|
|
501
|
-
manualChunks: void 0
|
|
481
|
+
entryFileNames: rollupOutputOptions.entryFileNames
|
|
502
482
|
}
|
|
503
483
|
}
|
|
484
|
+
},
|
|
485
|
+
esbuild: false,
|
|
486
|
+
optimizeDeps: {
|
|
487
|
+
esbuildOptions: {
|
|
488
|
+
target: "es5"
|
|
489
|
+
}
|
|
504
490
|
}
|
|
505
491
|
});
|
|
506
492
|
const _polyfillChunk = Array.isArray(res) ? res[0] : res;
|
|
@@ -528,13 +514,6 @@ function polyfillsPlugin(imports, excludeSystemJS) {
|
|
|
528
514
|
if (id === polyfillId) {
|
|
529
515
|
return [...imports].map((i) => `import "${i}";`).join("") + (excludeSystemJS ? "" : `import "systemjs/dist/s.min.js";`);
|
|
530
516
|
}
|
|
531
|
-
},
|
|
532
|
-
renderChunk(_, __, opts) {
|
|
533
|
-
if (!excludeSystemJS) {
|
|
534
|
-
opts.__vite_skip_esbuild__ = true;
|
|
535
|
-
opts.__vite_force_terser__ = true;
|
|
536
|
-
}
|
|
537
|
-
return null;
|
|
538
517
|
}
|
|
539
518
|
};
|
|
540
519
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -106,14 +106,20 @@ function viteLegacyPlugin(options = {}) {
|
|
|
106
106
|
}
|
|
107
107
|
const legacyConfigPlugin = {
|
|
108
108
|
name: "vite:legacy-config",
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
config(config2, env) {
|
|
110
|
+
if (env.command === "build") {
|
|
111
|
+
if (!config2.build) {
|
|
112
|
+
config2.build = {};
|
|
113
|
+
}
|
|
114
|
+
if (!config2.build.cssTarget) {
|
|
115
|
+
config2.build.cssTarget = "chrome61";
|
|
116
|
+
}
|
|
116
117
|
}
|
|
118
|
+
return {
|
|
119
|
+
define: {
|
|
120
|
+
"import.meta.env.LEGACY": env.command === "serve" || config2.build?.ssr ? false : legacyEnvVarMarker
|
|
121
|
+
}
|
|
122
|
+
};
|
|
117
123
|
}
|
|
118
124
|
};
|
|
119
125
|
const legacyGenerateBundlePlugin = {
|
|
@@ -132,6 +138,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
132
138
|
modernPolyfills
|
|
133
139
|
);
|
|
134
140
|
await buildPolyfillChunk(
|
|
141
|
+
config.mode,
|
|
135
142
|
modernPolyfills,
|
|
136
143
|
bundle,
|
|
137
144
|
facadeToModernPolyfillMap,
|
|
@@ -156,6 +163,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
156
163
|
legacyPolyfills
|
|
157
164
|
);
|
|
158
165
|
await buildPolyfillChunk(
|
|
166
|
+
config.mode,
|
|
159
167
|
legacyPolyfills,
|
|
160
168
|
bundle,
|
|
161
169
|
facadeToLegacyPolyfillMap,
|
|
@@ -400,34 +408,7 @@ function viteLegacyPlugin(options = {}) {
|
|
|
400
408
|
}
|
|
401
409
|
}
|
|
402
410
|
};
|
|
403
|
-
|
|
404
|
-
const legacyEnvPlugin = {
|
|
405
|
-
name: "vite:legacy-env",
|
|
406
|
-
config(config2, env) {
|
|
407
|
-
if (env) {
|
|
408
|
-
return {
|
|
409
|
-
define: {
|
|
410
|
-
"import.meta.env.LEGACY": env.command === "serve" || config2.build?.ssr ? false : legacyEnvVarMarker
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
} else {
|
|
414
|
-
envInjectionFailed = true;
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
configResolved(config2) {
|
|
418
|
-
if (envInjectionFailed) {
|
|
419
|
-
config2.logger.warn(
|
|
420
|
-
`[@vitejs/plugin-legacy] import.meta.env.LEGACY was not injected due to incompatible vite version (requires vite@^2.0.0-beta.69).`
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
return [
|
|
426
|
-
legacyConfigPlugin,
|
|
427
|
-
legacyGenerateBundlePlugin,
|
|
428
|
-
legacyPostPlugin,
|
|
429
|
-
legacyEnvPlugin
|
|
430
|
-
];
|
|
411
|
+
return [legacyConfigPlugin, legacyGenerateBundlePlugin, legacyPostPlugin];
|
|
431
412
|
}
|
|
432
413
|
async function detectPolyfills(code, targets, list) {
|
|
433
414
|
const babel2 = await loadBabel();
|
|
@@ -469,17 +450,17 @@ function createBabelPresetEnvOptions(targets, {
|
|
|
469
450
|
ignoreBrowserslistConfig
|
|
470
451
|
};
|
|
471
452
|
}
|
|
472
|
-
async function buildPolyfillChunk(imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS) {
|
|
453
|
+
async function buildPolyfillChunk(mode, imports, bundle, facadeToChunkMap, buildOptions, format, rollupOutputOptions, excludeSystemJS) {
|
|
473
454
|
let { minify, assetsDir } = buildOptions;
|
|
474
455
|
minify = minify ? "terser" : false;
|
|
475
456
|
const res = await build({
|
|
457
|
+
mode,
|
|
476
458
|
root: path.dirname(fileURLToPath(import.meta.url)),
|
|
477
459
|
configFile: false,
|
|
478
460
|
logLevel: "error",
|
|
479
461
|
plugins: [polyfillsPlugin(imports, excludeSystemJS)],
|
|
480
462
|
build: {
|
|
481
463
|
write: false,
|
|
482
|
-
target: "es5",
|
|
483
464
|
minify,
|
|
484
465
|
assetsDir,
|
|
485
466
|
rollupOptions: {
|
|
@@ -488,10 +469,15 @@ async function buildPolyfillChunk(imports, bundle, facadeToChunkMap, buildOption
|
|
|
488
469
|
},
|
|
489
470
|
output: {
|
|
490
471
|
format,
|
|
491
|
-
entryFileNames: rollupOutputOptions.entryFileNames
|
|
492
|
-
manualChunks: void 0
|
|
472
|
+
entryFileNames: rollupOutputOptions.entryFileNames
|
|
493
473
|
}
|
|
494
474
|
}
|
|
475
|
+
},
|
|
476
|
+
esbuild: false,
|
|
477
|
+
optimizeDeps: {
|
|
478
|
+
esbuildOptions: {
|
|
479
|
+
target: "es5"
|
|
480
|
+
}
|
|
495
481
|
}
|
|
496
482
|
});
|
|
497
483
|
const _polyfillChunk = Array.isArray(res) ? res[0] : res;
|
|
@@ -519,13 +505,6 @@ function polyfillsPlugin(imports, excludeSystemJS) {
|
|
|
519
505
|
if (id === polyfillId) {
|
|
520
506
|
return [...imports].map((i) => `import "${i}";`).join("") + (excludeSystemJS ? "" : `import "systemjs/dist/s.min.js";`);
|
|
521
507
|
}
|
|
522
|
-
},
|
|
523
|
-
renderChunk(_, __, opts) {
|
|
524
|
-
if (!excludeSystemJS) {
|
|
525
|
-
opts.__vite_skip_esbuild__ = true;
|
|
526
|
-
opts.__vite_force_terser__ = true;
|
|
527
|
-
}
|
|
528
|
-
return null;
|
|
529
508
|
}
|
|
530
509
|
};
|
|
531
510
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-legacy",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"files": [
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/standalone": "^7.18.
|
|
39
|
-
"core-js": "^3.
|
|
38
|
+
"@babel/standalone": "^7.18.13",
|
|
39
|
+
"core-js": "^3.25.0",
|
|
40
40
|
"magic-string": "^0.26.2",
|
|
41
41
|
"regenerator-runtime": "^0.13.9",
|
|
42
|
-
"systemjs": "^6.12.
|
|
42
|
+
"systemjs": "^6.12.4"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"terser": "^5.4.0",
|
|
46
46
|
"vite": "^3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "^7.18.
|
|
49
|
+
"@babel/core": "^7.18.13",
|
|
50
50
|
"vite": "workspace:*"
|
|
51
51
|
}
|
|
52
52
|
}
|