@vitejs/plugin-legacy
Advanced tools
+39
-39
| import { createRequire } from "node:module"; | ||
| import path from "node:path"; | ||
| import path$1 from "node:path"; | ||
| import crypto from "node:crypto"; | ||
@@ -144,3 +144,3 @@ import { fileURLToPath } from "node:url"; | ||
| function getBaseInHTML(urlRelativePath, config) { | ||
| return config.base === "./" || config.base === "" ? path.posix.join(path.posix.relative(urlRelativePath, "").slice(0, -2), "./") : config.base; | ||
| return config.base === "./" || config.base === "" ? path$1.posix.join(path$1.posix.relative(urlRelativePath, "").slice(0, -2), "./") : config.base; | ||
| } | ||
@@ -154,4 +154,4 @@ function joinUrlSegments(a, b) { | ||
| function toAssetPathFromHtml(filename, htmlPath, config) { | ||
| const relativeUrlPath = normalizePath(path.relative(config.root, htmlPath)); | ||
| const toRelative = (filename$1, _hostId) => getBaseInHTML(relativeUrlPath, config) + filename$1; | ||
| const relativeUrlPath = normalizePath(path$1.relative(config.root, htmlPath)); | ||
| const toRelative = (filename, _hostId) => getBaseInHTML(relativeUrlPath, config) + filename; | ||
| return toOutputFilePathInHtml(filename, "asset", htmlPath, "html", config, toRelative); | ||
@@ -207,22 +207,22 @@ } | ||
| name: "vite:legacy-config", | ||
| async config(config$1, env$1) { | ||
| if (env$1.command === "build" && !config$1.build?.ssr) { | ||
| if (!config$1.build) config$1.build = {}; | ||
| if (genLegacy && !config$1.build.cssTarget) config$1.build.cssTarget = "chrome61"; | ||
| async config(config, env) { | ||
| if (env.command === "build" && !config.build?.ssr) { | ||
| if (!config.build) config.build = {}; | ||
| if (genLegacy && !config.build.cssTarget) config.build.cssTarget = "chrome61"; | ||
| if (genLegacy) { | ||
| overriddenBuildTarget = config$1.build.target !== void 0; | ||
| overriddenBuildTarget = config.build.target !== void 0; | ||
| overriddenDefaultModernTargets = options.modernTargets !== void 0; | ||
| } else overriddenBuildTargetOnlyModern = config$1.build.target !== void 0; | ||
| } else overriddenBuildTargetOnlyModern = config.build.target !== void 0; | ||
| if (options.modernTargets) { | ||
| const { default: browserslistToEsbuild } = await import("browserslist-to-esbuild"); | ||
| config$1.build.target = browserslistToEsbuild(options.modernTargets); | ||
| } else config$1.build.target = modernTargetsEsbuild; | ||
| config.build.target = browserslistToEsbuild(options.modernTargets); | ||
| } else config.build.target = modernTargetsEsbuild; | ||
| } | ||
| return { define: { "import.meta.env.LEGACY": env$1.command === "serve" || config$1.build?.ssr ? false : legacyEnvVarMarker } }; | ||
| return { define: { "import.meta.env.LEGACY": env.command === "serve" || config.build?.ssr ? false : legacyEnvVarMarker } }; | ||
| }, | ||
| configResolved(config$1) { | ||
| if (overriddenBuildTarget) config$1.logger.warn(import_picocolors.default.yellow(`plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`)); | ||
| if (overriddenBuildTargetOnlyModern) config$1.logger.warn(import_picocolors.default.yellow(`plugin-legacy overrode 'build.target'. You should pass 'modernTargets' as an option to this plugin with the list of browsers to support instead.`)); | ||
| if (overriddenDefaultModernTargets) config$1.logger.warn(import_picocolors.default.yellow(`plugin-legacy 'modernTargets' option overrode the builtin targets of modern chunks. Some versions of browsers between legacy and modern may not be supported.`)); | ||
| if (config$1.isWorker) config$1.logger.warn(import_picocolors.default.yellow(`plugin-legacy should not be passed to 'worker.plugins'. Pass to 'plugins' instead. Note that generating legacy chunks for workers are not supported by plugin-legacy.`)); | ||
| configResolved(config) { | ||
| if (overriddenBuildTarget) config.logger.warn(import_picocolors.default.yellow(`plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`)); | ||
| if (overriddenBuildTargetOnlyModern) config.logger.warn(import_picocolors.default.yellow(`plugin-legacy overrode 'build.target'. You should pass 'modernTargets' as an option to this plugin with the list of browsers to support instead.`)); | ||
| if (overriddenDefaultModernTargets) config.logger.warn(import_picocolors.default.yellow(`plugin-legacy 'modernTargets' option overrode the builtin targets of modern chunks. Some versions of browsers between legacy and modern may not be supported.`)); | ||
| if (config.isWorker) config.logger.warn(import_picocolors.default.yellow(`plugin-legacy should not be passed to 'worker.plugins'. Pass to 'plugins' instead. Note that generating legacy chunks for workers are not supported by plugin-legacy.`)); | ||
| } | ||
@@ -238,3 +238,3 @@ }, | ||
| if (!isLegacyBundle(bundle)) { | ||
| for (const { modern } of chunkFileNameToPolyfills.values()) modern.forEach((p$1) => modernPolyfills.add(p$1)); | ||
| for (const { modern } of chunkFileNameToPolyfills.values()) modern.forEach((p) => modernPolyfills.add(p)); | ||
| if (!modernPolyfills.size) return; | ||
@@ -246,3 +246,3 @@ if (isDebug) console.log(`[@vitejs/plugin-legacy] modern polyfills:`, modernPolyfills); | ||
| if (!genLegacy) return; | ||
| for (const { legacy } of chunkFileNameToPolyfills.values()) legacy.forEach((p$1) => legacyPolyfills.add(p$1)); | ||
| for (const { legacy } of chunkFileNameToPolyfills.values()) legacy.forEach((p) => legacyPolyfills.add(p)); | ||
| if (options.polyfills !== false) await detectPolyfills(`Promise.resolve(); Promise.all();`, targets, assumptions, legacyPolyfills); | ||
@@ -270,3 +270,3 @@ if (legacyPolyfills.size || !options.externalSystemJS) { | ||
| const getLegacyOutputFileName = (fileNames, defaultFileName = "[name]-legacy-[hash].js") => { | ||
| if (!fileNames) return path.posix.join(config.build.assetsDir, defaultFileName); | ||
| if (!fileNames) return path$1.posix.join(config.build.assetsDir, defaultFileName); | ||
| return (chunkInfo) => { | ||
@@ -280,8 +280,8 @@ let fileName = typeof fileNames === "function" ? fileNames(chunkInfo) : fileNames; | ||
| }; | ||
| const createLegacyOutput = (options$1 = {}) => { | ||
| const createLegacyOutput = (options = {}) => { | ||
| return { | ||
| ...options$1, | ||
| ...options, | ||
| format: "esm", | ||
| entryFileNames: getLegacyOutputFileName(options$1.entryFileNames), | ||
| chunkFileNames: getLegacyOutputFileName(options$1.chunkFileNames), | ||
| entryFileNames: getLegacyOutputFileName(options.entryFileNames), | ||
| chunkFileNames: getLegacyOutputFileName(options.chunkFileNames), | ||
| minify: false | ||
@@ -328,4 +328,4 @@ }; | ||
| const sourceMaps = !!config.build.sourcemap; | ||
| const babel$1 = await loadBabel(); | ||
| const resultSystem = babel$1.transform(raw, { | ||
| const babel = await loadBabel(); | ||
| const resultSystem = babel.transform(raw, { | ||
| babelrc: false, | ||
@@ -364,4 +364,4 @@ configFile: false, | ||
| let result; | ||
| if (resultSystem) result = babel$1.transformFromAstSync(resultSystem.ast, void 0, babelTransformOptions); | ||
| else result = babel$1.transform(raw, babelTransformOptions); | ||
| if (resultSystem) result = babel.transformFromAstSync(resultSystem.ast, void 0, babelTransformOptions); | ||
| else result = babel.transform(raw, babelTransformOptions); | ||
| if (result) return { | ||
@@ -484,3 +484,3 @@ code: result.code, | ||
| mode, | ||
| root: path.dirname(fileURLToPath(import.meta.url)), | ||
| root: path$1.dirname(fileURLToPath(import.meta.url)), | ||
| configFile: false, | ||
@@ -568,7 +568,7 @@ logLevel: "error", | ||
| name: "vite-remove-polyfill-import", | ||
| post({ path: path$1 }) { | ||
| path$1.get("body").forEach((p$1) => { | ||
| if (t.isImportDeclaration(p$1.node)) { | ||
| polyfills.add(p$1.node.source.value); | ||
| p$1.remove(); | ||
| post({ path }) { | ||
| path.get("body").forEach((p) => { | ||
| if (t.isImportDeclaration(p.node)) { | ||
| polyfills.add(p.node.source.value); | ||
| p.remove(); | ||
| } | ||
@@ -582,4 +582,4 @@ }); | ||
| name: "vite-replace-env-legacy", | ||
| visitor: { Identifier(path$1) { | ||
| if (path$1.node.name === legacyEnvVarMarker) path$1.replaceWith(t.booleanLiteral(true)); | ||
| visitor: { Identifier(path) { | ||
| if (path.node.name === legacyEnvVarMarker) path.replaceWith(t.booleanLiteral(true)); | ||
| } } | ||
@@ -593,6 +593,6 @@ }); | ||
| name: "vite-wrap-iife", | ||
| post({ path: path$1 }) { | ||
| post({ path }) { | ||
| if (!this.isWrapped) { | ||
| this.isWrapped = true; | ||
| path$1.replaceWith(t.program(buildIIFE({ body: path$1.node.body }))); | ||
| path.replaceWith(t.program(buildIIFE({ body: path.node.body }))); | ||
| } | ||
@@ -599,0 +599,0 @@ } |
+17
-6
| { | ||
| "name": "@vitejs/plugin-legacy", | ||
| "version": "8.0.0-beta.0", | ||
| "version": "8.0.0-beta.1", | ||
| "type": "module", | ||
@@ -31,9 +31,9 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@babel/core": "^7.28.5", | ||
| "@babel/core": "^7.28.6", | ||
| "@babel/plugin-transform-dynamic-import": "^7.27.1", | ||
| "@babel/plugin-transform-modules-systemjs": "^7.28.5", | ||
| "@babel/preset-env": "^7.28.5", | ||
| "@babel/preset-env": "^7.28.6", | ||
| "babel-plugin-polyfill-corejs3": "^0.13.0", | ||
| "babel-plugin-polyfill-regenerator": "^0.6.5", | ||
| "browserslist": "^4.28.0", | ||
| "browserslist": "^4.28.1", | ||
| "browserslist-to-esbuild": "^2.1.1", | ||
@@ -52,5 +52,16 @@ "core-js": "^3.47.0", | ||
| "picocolors": "^1.1.1", | ||
| "tsdown": "^0.16.8", | ||
| "vite": "8.0.0-beta.0" | ||
| "tsdown": "^0.19.0", | ||
| "vite": "8.0.0-beta.9" | ||
| }, | ||
| "compatiblePackages": { | ||
| "schemaVersion": 1, | ||
| "rolldown": { | ||
| "type": "incompatible", | ||
| "reason": "Only supports Vite" | ||
| }, | ||
| "rollup": { | ||
| "type": "incompatible", | ||
| "reason": "Only supports Vite" | ||
| } | ||
| }, | ||
| "scripts": { | ||
@@ -57,0 +68,0 @@ "dev": "tsdown --watch", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
39852
0.36%0
-100%Updated
Updated
Updated