From 16c80c8331284eae70d7cdcd07f5bc5e5417bb70 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Sat, 15 Feb 2025 19:41:17 +0900 Subject: [PATCH 1/4] drop cjs: source --- eslint.config.mjs | 3 +- packages/core-base/index.js | 7 ---- packages/core-base/package.json | 10 +---- packages/core/index.js | 7 ---- packages/core/package.json | 8 ---- packages/devtools-types/index.js | 7 ---- packages/devtools-types/package.json | 12 +----- packages/message-compiler/index.js | 7 ---- packages/message-compiler/package.json | 8 ---- packages/petite-vue-i18n/index.js | 7 ---- packages/petite-vue-i18n/package.json | 8 ---- packages/shared/index.js | 7 ---- packages/shared/package.json | 11 +----- packages/vue-i18n-core/index.js | 7 ---- packages/vue-i18n-core/package.json | 15 ------- packages/vue-i18n-core/petite.js | 7 ---- packages/vue-i18n/index.js | 7 ---- packages/vue-i18n/package.json | 8 ---- rollup.config.mjs | 36 ++--------------- scripts/build-rolldown.ts | 4 +- scripts/build.ts | 4 +- scripts/dev.ts | 2 +- scripts/rolldown.ts | 54 ++++---------------------- scripts/utils.ts | 3 +- 24 files changed, 23 insertions(+), 226 deletions(-) delete mode 100644 packages/core-base/index.js delete mode 100644 packages/core/index.js delete mode 100644 packages/devtools-types/index.js delete mode 100644 packages/message-compiler/index.js delete mode 100644 packages/petite-vue-i18n/index.js delete mode 100644 packages/shared/index.js delete mode 100644 packages/vue-i18n-core/index.js delete mode 100644 packages/vue-i18n-core/petite.js delete mode 100644 packages/vue-i18n/index.js diff --git a/eslint.config.mjs b/eslint.config.mjs index add504a49..66f6631d4 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -51,7 +51,7 @@ export default [ } }, { - files: ['**/*.js', '**/*.cjs', '**/*.mjs'], + files: ['**/*.js', '**/*.mjs'], ...ts.configs.disableTypeChecked }, @@ -95,7 +95,6 @@ export default [ 'shim.d.ts', 'temp/**', '.eslintcache', - '.eslintrc.cjs', 'packages/*/vite.config.ts', 'packages/*/index.js', 'packages/vue-i18n-core/petite.js', diff --git a/packages/core-base/index.js b/packages/core-base/index.js deleted file mode 100644 index 9a6a8be0a..000000000 --- a/packages/core-base/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/core-base.prod.cjs') -} else { - module.exports = require('./dist/core-base.cjs') -} diff --git a/packages/core-base/package.json b/packages/core-base/package.json index 1bfc37639..8ac427ac3 100644 --- a/packages/core-base/package.json +++ b/packages/core-base/package.json @@ -24,10 +24,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/core-base.mjs", "unpkg": "dist/core-base.global.js", "jsdelivr": "dist/core-base.global.js", @@ -47,7 +45,6 @@ "formats": [ "mjs", "browser", - "cjs", "global" ] }, @@ -58,14 +55,9 @@ "browser": "./dist/core-base.esm-browser.js", "node": { "import": { - "production": "./dist/core-base.prod.cjs", + "production": "./dist/core-base.prod.mjs", "development": "./dist/core-base.mjs", "default": "./dist/core-base.mjs" - }, - "require": { - "production": "./dist/core-base.prod.cjs", - "development": "./dist/core-base.cjs", - "default": "./index.js" } } }, diff --git a/packages/core/index.js b/packages/core/index.js deleted file mode 100644 index e4e67ff60..000000000 --- a/packages/core/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/core.prod.cjs') -} else { - module.exports = require('./dist/core.cjs') -} diff --git a/packages/core/package.json b/packages/core/package.json index e95d19732..5c42d2d2a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -24,10 +24,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/core.mjs", "unpkg": "dist/core.global.js", "jsdelivr": "dist/core.global.js", @@ -48,7 +46,6 @@ "mjs-node-runtime", "browser", "browser-runtime", - "cjs", "global", "global-runtime" ] @@ -63,11 +60,6 @@ "production": "./dist/core.prod.node.mjs", "development": "./dist/core.node.mjs", "default": "./dist/core.node.mjs" - }, - "require": { - "production": "./dist/core.prod.cjs", - "development": "./dist/core.cjs", - "default": "./index.js" } } }, diff --git a/packages/devtools-types/index.js b/packages/devtools-types/index.js deleted file mode 100644 index d64c0e375..000000000 --- a/packages/devtools-types/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/devtools-types.prod.cjs') -} else { - module.exports = require('./dist/devtools-types.cjs') -} diff --git a/packages/devtools-types/package.json b/packages/devtools-types/package.json index fd9821ae9..5b9783fc9 100644 --- a/packages/devtools-types/package.json +++ b/packages/devtools-types/package.json @@ -23,10 +23,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/devtools-types.mjs", "types": "dist/devtools-types.d.ts", "dependencies": { @@ -39,8 +37,7 @@ "buildOptions": { "name": "IntlifyDevToolsTypes", "formats": [ - "mjs", - "cjs" + "mjs" ] }, "exports": { @@ -49,14 +46,9 @@ "import": "./dist/devtools-types.mjs", "node": { "import": { - "production": "./dist/devtools-types.prod.cjs", + "production": "./dist/devtools-types.prod.mjs", "development": "./dist/devtools-types.mjs", "default": "./dist/devtools-types.mjs" - }, - "require": { - "production": "./dist/devtools-types.prod.cjs", - "development": "./dist/devtools-types.cjs", - "default": "./index.js" } } }, diff --git a/packages/message-compiler/index.js b/packages/message-compiler/index.js deleted file mode 100644 index 5109c761e..000000000 --- a/packages/message-compiler/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/message-compiler.prod.cjs') -} else { - module.exports = require('./dist/message-compiler.cjs') -} diff --git a/packages/message-compiler/package.json b/packages/message-compiler/package.json index d94c560a0..33d70c91c 100644 --- a/packages/message-compiler/package.json +++ b/packages/message-compiler/package.json @@ -24,10 +24,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/message-compiler.mjs", "unpkg": "dist/message-compiler.global.js", "jsdelivr": "dist/message-compiler.global.js", @@ -45,7 +43,6 @@ "mjs", "mjs-node", "browser", - "cjs", "global" ], "enableFullBundleForEsmBrowser": true @@ -60,11 +57,6 @@ "production": "./dist/message-compiler.node.mjs", "development": "./dist/message-compiler.node.mjs", "default": "./dist/message-compiler.node.mjs" - }, - "require": { - "production": "./dist/message-compiler.prod.cjs", - "development": "./dist/message-compiler.cjs", - "default": "./index.js" } } }, diff --git a/packages/petite-vue-i18n/index.js b/packages/petite-vue-i18n/index.js deleted file mode 100644 index a93b001de..000000000 --- a/packages/petite-vue-i18n/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/petite-vue-i18n.prod.cjs') -} else { - module.exports = require('./dist/petite-vue-i18n.cjs') -} diff --git a/packages/petite-vue-i18n/package.json b/packages/petite-vue-i18n/package.json index 97162f603..ece619e68 100644 --- a/packages/petite-vue-i18n/package.json +++ b/packages/petite-vue-i18n/package.json @@ -26,10 +26,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/petite-vue-i18n.mjs", "unpkg": "dist/petite-vue-i18n.global.js", "jsdelivr": "dist/petite-vue-i18n.global.js", @@ -58,7 +56,6 @@ "mjs-node-runtime", "browser", "browser-runtime", - "cjs", "global", "global-runtime" ] @@ -73,11 +70,6 @@ "production": "./dist/petite-vue-i18n.node.mjs", "development": "./dist/petite-vue-i18n.node.mjs", "default": "./dist/petite-vue-i18n.node.mjs" - }, - "require": { - "production": "./dist/petite-vue-i18n.prod.cjs", - "development": "./dist/petite-vue-i18n.cjs", - "default": "./index.js" } } }, diff --git a/packages/shared/index.js b/packages/shared/index.js deleted file mode 100644 index 6aa3731fd..000000000 --- a/packages/shared/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/shared.prod.cjs') -} else { - module.exports = require('./dist/shared.cjs') -} diff --git a/packages/shared/package.json b/packages/shared/package.json index 385b1af68..cc8dad5a6 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -23,10 +23,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/shared.mjs", "types": "dist/shared.d.ts", "engines": { @@ -36,8 +34,7 @@ "name": "IntlifyShared", "formats": [ "mjs", - "browser", - "cjs" + "browser" ] }, "exports": { @@ -47,14 +44,8 @@ "browser": "./dist/shared.esm-browser.js", "node": { "import": { - "production": "./dist/shared.prod.cjs", "development": "./dist/shared.mjs", "default": "./dist/shared.mjs" - }, - "require": { - "production": "./dist/shared.prod.cjs", - "development": "./dist/shared.cjs", - "default": "./index.js" } } }, diff --git a/packages/vue-i18n-core/index.js b/packages/vue-i18n-core/index.js deleted file mode 100644 index ee69d2b71..000000000 --- a/packages/vue-i18n-core/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/vue-i18n-core.prod.cjs') -} else { - module.exports = require('./dist/vue-i18n-core.cjs') -} diff --git a/packages/vue-i18n-core/package.json b/packages/vue-i18n-core/package.json index c83192054..3fe37f572 100644 --- a/packages/vue-i18n-core/package.json +++ b/packages/vue-i18n-core/package.json @@ -26,10 +26,8 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist" ], - "main": "index.js", "module": "dist/vue-i18n-core.mjs", "unpkg": "dist/vue-i18n-core.global.js", "jsdelivr": "dist/vue-i18n-core.global.js", @@ -53,7 +51,6 @@ "formats": [ "mjs", "browser", - "cjs", "global" ] }, @@ -64,14 +61,8 @@ "browser": "./dist/vue-i18n-core.esm-browser.js", "node": { "import": { - "production": "./dist/vue-i18n-core.prod.cjs", "development": "./dist/vue-i18n-core.mjs", "default": "./dist/vue-i18n-core.mjs" - }, - "require": { - "production": "./dist/vue-i18n-core.prod.cjs", - "development": "./dist/vue-i18n-core.cjs", - "default": "./index.js" } } }, @@ -81,14 +72,8 @@ "browser": "./dist/petite-vue-i18n-core.esm-browser.js", "node": { "import": { - "production": "./petite-dist/vue-i18n-core.prod.cjs", "development": "./petite-dist/vue-i18n-core.mjs", "default": "./dist/petite-vue-i18n-core.mjs" - }, - "require": { - "production": "./dist/petite-vue-i18n-core.prod.cjs", - "development": "./dist/petite-vue-i18n-core.cjs", - "default": "./petite.js" } } }, diff --git a/packages/vue-i18n-core/petite.js b/packages/vue-i18n-core/petite.js deleted file mode 100644 index 44e0a7a2b..000000000 --- a/packages/vue-i18n-core/petite.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/petite-vue-i18n-core.prod.cjs') -} else { - module.exports = require('./dist/petite-vue-i18n-core.cjs') -} diff --git a/packages/vue-i18n/index.js b/packages/vue-i18n/index.js deleted file mode 100644 index 607e38d2b..000000000 --- a/packages/vue-i18n/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/vue-i18n.prod.cjs') -} else { - module.exports = require('./dist/vue-i18n.cjs') -} diff --git a/packages/vue-i18n/package.json b/packages/vue-i18n/package.json index 052543701..0c883d2b5 100644 --- a/packages/vue-i18n/package.json +++ b/packages/vue-i18n/package.json @@ -25,11 +25,9 @@ "url": "https://github.com/intlify/vue-i18n/issues" }, "files": [ - "index.js", "dist", "vetur" ], - "main": "index.js", "module": "dist/vue-i18n.mjs", "unpkg": "dist/vue-i18n.global.js", "jsdelivr": "dist/vue-i18n.global.js", @@ -58,7 +56,6 @@ "mjs-node-runtime", "browser", "browser-runtime", - "cjs", "global", "global-runtime" ] @@ -73,11 +70,6 @@ "production": "./dist/vue-i18n.node.mjs", "development": "./dist/vue-i18n.node.mjs", "default": "./dist/vue-i18n.node.mjs" - }, - "require": { - "production": "./dist/vue-i18n.prod.cjs", - "development": "./dist/vue-i18n.cjs", - "default": "./index.js" } } }, diff --git a/rollup.config.mjs b/rollup.config.mjs index d017270bb..9231b59a2 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -34,10 +34,8 @@ let hasTSChecked = false function resolveStubs(name, ns = '') { return { - [`dist/${ns}${name}.cjs`]: `${ns}${name}.cjs.js`, [`dist/${ns}${name}.mjs`]: `${ns}${name}.esm-bundler.js`, [`dist/${ns}${name}.runtime.mjs`]: `${ns}${name}.runtime.esm-bundler.js`, - [`dist/${ns}${name}.prod.cjs`]: `${ns}${name}.cjs.prod.js` } } @@ -55,10 +53,6 @@ function resolveOutputConfigs(name, ns = '') { file: `dist/${ns}${name}.esm-browser.js`, format: `es` }, - cjs: { - file: `dist/${ns}${name}.cjs`, - format: `cjs` - }, global: { file: `dist/${ns}${name}.global.js`, format: `iife` @@ -84,7 +78,7 @@ function resolveOutputConfigs(name, ns = '') { } const outputConfigs = resolveOutputConfigs(name) -const defaultFormats = ['esm-bundler', 'cjs'] +const defaultFormats = ['esm-bundler'] const inlineFormats = process.env.FORMATS && process.env.FORMATS.split(',') const packageFormats = inlineFormats || packageOptions.formats || defaultFormats @@ -112,12 +106,6 @@ if (process.env.NODE_ENV === 'production') { if (packageOptions.prod === false) { return } - if (format === 'cjs') { - packageConfigs.push(createProductionConfig(format, name)) - if (name === 'vue-i18n-core') { - packageConfigs.push(createProductionConfig(format, name, 'petite-')) - } - } if (/^(global|browser)(-runtime)?/.test(format)) { packageConfigs.push(createMinifiedConfig(format, outputConfigs[format])) if (name === 'vue-i18n-core') { @@ -158,7 +146,7 @@ function createConfig(format, _output, plugins = []) { process.env.__DEV__ === 'false' || /\.prod\.[cm]?js$/.test(output.file) const isBundlerESMBuild = /mjs/.test(format) const isBrowserESMBuild = /browser/.test(format) - const isNodeBuild = output.file.includes('.node.') || format === 'cjs' + const isNodeBuild = output.file.includes('.node.') const isGlobalBuild = /global/.test(format) const isRuntimeOnlyBuild = /runtime/.test(format) const isLite = /petite-vue-i18n/.test(output.file) @@ -209,10 +197,7 @@ function createConfig(format, _output, plugins = []) { ...Object.keys(pkg.peerDependencies || {}) ] - const nodePlugins = - // packageOptions.enableNonBrowserBranches && format !== 'cjs' - format !== 'cjs' - ? [ + const nodePlugins = [ require('@rollup/plugin-node-resolve').nodeResolve(), require('@rollup/plugin-commonjs')({ sourceMap: false @@ -220,7 +205,6 @@ function createConfig(format, _output, plugins = []) { require('rollup-plugin-node-builtins')(), require('rollup-plugin-node-globals')() ] - : [] return { input: resolve(entryFile), @@ -253,10 +237,7 @@ function createConfig(format, _output, plugins = []) { const stub = stubs[rawFile] if (!stub) return - const contents = - format === 'cjs' - ? `module.exports = require('../${rawFile}')` - : `export * from '../${rawFile}'` + const contents = `export * from '../${rawFile}'` await fs.writeFile(resolve(`dist/${stub}`), contents) console.log(`created stub ${pc.bold(`dist/${stub}`)}`) @@ -394,15 +375,6 @@ function createReplacePlugin( }) } -function createProductionConfig(format, name, ns = '') { - const extension = format === 'cjs' || format === 'mjs' ? format : 'js' - const descriptor = format === 'cjs' || format === 'mjs' ? '' : `.${format}` - return createConfig(format, { - file: `dist/${ns}${name}${descriptor}.prod.${extension}`, - format: outputConfigs[format].format - }) -} - function createMinifiedConfig(format, output) { const newOutput = { file: output.file.replace(/\.js$/, '.prod.js'), diff --git a/scripts/build-rolldown.ts b/scripts/build-rolldown.ts index 96c7ec98a..533b17beb 100644 --- a/scripts/build-rolldown.ts +++ b/scripts/build-rolldown.ts @@ -3,14 +3,14 @@ Produces production builds and stitches together d.ts files. To specify the package to build, simply pass its name and the desired build formats to output (defaults to `buildOptions.formats` specified in that package, -or "esm,cjs"): +or "esm"): ``` # name supports fuzzy match. will build all packages with name containing "core-base": pnpm build core-base # specify the format to output -pnpm build core --formats cjs +pnpm build core --formats mjs ``` */ diff --git a/scripts/build.ts b/scripts/build.ts index 3ca8614c8..ff363d775 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -3,14 +3,14 @@ Produces production builds and stitches together d.ts files. To specify the package to build, simply pass its name and the desired build formats to output (defaults to `buildOptions.formats` specified in that package, -or "esm,cjs"): +or "esm"): ``` # name supports fuzzy match. will build all packages with name containing "core-base": pnpm build core-base # specify the format to output -pnpm build core --formats cjs +pnpm build core --formats esm ``` */ diff --git a/scripts/dev.ts b/scripts/dev.ts index 7caf00bb0..b45459ce8 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -9,7 +9,7 @@ formats to watch (defaults to "global"): pnpm dev core-base # specify the format to output -pnpm dev core --formats cjs +pnpm dev core --formats mjs # Can also drop all __DEV__ blocks with: __DEV__=false pnpm run dev diff --git a/scripts/rolldown.ts b/scripts/rolldown.ts index 456070030..dedbf2381 100644 --- a/scripts/rolldown.ts +++ b/scripts/rolldown.ts @@ -55,10 +55,8 @@ export function createConfigsForPackage({ function resolveStubs(name: string, ns = '') { return { - [`dist/${ns}${name}.cjs`]: `${ns}${name}.cjs.js`, [`dist/${ns}${name}.mjs`]: `${ns}${name}.esm-bundler.js`, - [`dist/${ns}${name}.runtime.mjs`]: `${ns}${name}.runtime.esm-bundler.js`, - [`dist/${ns}${name}.prod.cjs`]: `${ns}${name}.cjs.prod.js` + [`dist/${ns}${name}.runtime.mjs`]: `${ns}${name}.runtime.esm-bundler.js` } } @@ -79,10 +77,6 @@ export function createConfigsForPackage({ file: resolve(`dist/${ns}${name}.esm-browser.js`), format: `es` }, - cjs: { - file: resolve(`dist/${ns}${name}.cjs`), - format: `cjs` - }, global: { file: resolve(`dist/${ns}${name}.global.js`), format: `iife` @@ -114,10 +108,7 @@ export function createConfigsForPackage({ const outputConfigs = resolveOutputConfigs(name) - const resolvedFormats = ( - formats || - packageOptions.formats || ['esm-bundler', 'cjs'] - ) + const resolvedFormats = (formats || packageOptions.formats || ['esm-bundler']) .filter(Boolean) .filter((format: string) => outputConfigs[format]) @@ -144,12 +135,6 @@ export function createConfigsForPackage({ if (packageOptions.prod === false) { return } - if (format === 'cjs') { - packageConfigs.push(createProductionConfig(format, name)) - if (name === 'vue-i18n-core') { - packageConfigs.push(createProductionConfig(format, name, 'petite-')) - } - } if (/^(global|browser)(-runtime)?/.test(format)) { packageConfigs.push(createMinifiedConfig(format, outputConfigs[format])) if (name === 'vue-i18n-core') { @@ -178,9 +163,7 @@ export function createConfigsForPackage({ const isBundlerESMBuild = /mjs/.test(format) const isBrowserESMBuild = /browser/.test(format) && !packageOptions.enableNonBrowserBranches - // const isCJSBuild = format === 'cjs' - const isNodeBuild = - String(output.file).includes('.node.') || format === 'cjs' + const isNodeBuild = String(output.file).includes('.node.') const isGlobalBuild = /global/.test(format) const isRuntimeOnlyBuild = /runtime/.test(format) const isLite = /petite-vue-i18n/.test(String(output.file)) @@ -189,9 +172,6 @@ export function createConfigsForPackage({ output.sourcemap = sourceMap output.banner = banner output.externalLiveBindings = false - // if (isCJSBuild) { - // output.esModule = true - // } if ( name === 'vue-i18n' || name === 'vue-i18n-core' || @@ -320,11 +300,9 @@ export function createConfigsForPackage({ } function resolveNodePlugins() { - const nodePlugins = - (format === 'cjs' && Object.keys(pkg.devDependencies || {}).length) || - packageOptions.enableNonBrowserBranches - ? [...(format === 'cjs' ? [] : [polyfillNode()])] - : [] + const nodePlugins = packageOptions.enableNonBrowserBranches + ? [...[polyfillNode()]] + : [] return nodePlugins } @@ -334,7 +312,7 @@ export function createConfigsForPackage({ // used alone. external: resolveExternal(), define: resolveDefine(), - platform: format === 'cjs' ? 'node' : 'browser', + platform: 'browser', resolve: { alias: entries }, @@ -354,10 +332,7 @@ export function createConfigsForPackage({ } const filename = path.basename(rawFile) - const contents = - format === 'cjs' - ? `module.exports = require('./${filename}')` - : `export * from './${filename}'` + const contents = `export * from './${filename}'` await fs.writeFile(stub, contents) // console.log(`created stub ${pc.bold(path.join('packages', target, 'dist', path.basename(stub)))}`) @@ -372,19 +347,6 @@ export function createConfigsForPackage({ } } - function createProductionConfig( - format: string, - name: string, - ns = '' - ): RolldownOptions { - const extension = format === 'cjs' || format === 'mjs' ? format : 'js' - const descriptor = format === 'cjs' || format === 'mjs' ? '' : `.${format}` - return createConfig(format, { - file: resolve(`dist/${ns}${name}${descriptor}.prod.${extension}`), - format: outputConfigs[format].format - }) - } - function createMinifiedConfig( format: string, output: OutputOptions diff --git a/scripts/utils.ts b/scripts/utils.ts index 564bcf324..b938e5daf 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -113,8 +113,7 @@ export async function checkSizeDistFiles(target: string) { return dirs.filter(file => /^(message-compiler|core|vue-i18n|petite-vue-i18n)/.test(file)) .filter(file => !/^core-base/.test(file)) .filter(file => !/^vue-i18n-core/.test(file)) - .filter(file => /prod.(cjs|js)$/.test(file)) - .filter(file => !/cjs.prod.js$/.test(file)) + .filter(file => /prod\.js$/.test(file)) } export async function readJson(path: string) { From 6589929b08b03a3dbff5e177fb335182ff9cf0a1 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Sat, 15 Feb 2025 19:47:50 +0900 Subject: [PATCH 2/4] drop cjs: docs --- .github/CONTRIBUTING.md | 7 +------ docs/guide/extra/dist.md | 14 -------------- packages/core/README.md | 9 --------- packages/vue-i18n/README.md | 8 -------- 4 files changed, 1 insertion(+), 37 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 83104e241..0a8451787 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -103,11 +103,6 @@ By default, each package will be built in multiple distribution formats as speci - This means you **must** import everything from this file and this file only to ensure you are getting the same instance of code. - Hard-coded prod/dev branches, and the prod build is pre-minified (you will have to use different paths/aliases for dev/prod) -- **`cjs`** - - - For use in Node.js server-side rendering via `require()`. - - The dev/prod files are pre-built, but are dynamically required based on `process.env.NODE_ENV` in `index.js`, which is the default entry when you do `require('vue-i18n')`. - For example, to build `compiler` with the global build only: ```bash @@ -117,7 +112,7 @@ pnpm build -- message-compiler -f global Multiple formats can be specified as a comma-separated list: ```bash -pnpm build -- message-compiler -f esm-browser,cjs +pnpm build -- message-compiler -f esm-browser,global ``` #### Build with Source Maps diff --git a/docs/guide/extra/dist.md b/docs/guide/extra/dist.md index 1b8376078..c82161aa9 100644 --- a/docs/guide/extra/dist.md +++ b/docs/guide/extra/dist.md @@ -40,16 +40,6 @@ If you use `vue-i18n.runtime.esm-bundler.js`, you will need to precompile all lo ## For Node.js (Server-Side) -- **`vue-i18n.cjs(.prod).js`**: - - For CommonJS usage in Node.js - - For use in Node.js via `require()` - - If you bundle your app with webpack with `target: 'node'` and properly externalize `vue-i18n`, this is the build that will be loaded - - The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env``.NODE_ENV` - -:::tip Support Version -:new: 9.3+ -::: - - **`vue-i18n(.runtime).node.mjs`**: - For ES Modules usage in Node.js - For use in Node.js via `import` @@ -57,7 +47,3 @@ If you use `vue-i18n.runtime.esm-bundler.js`, you will need to precompile all lo - This module is proxy module of `vue-i18n(.runtime).mjs` - **`vue-i18n.runtime.node.mjs`**: is runtime only. - **`vue-i18n.node.mjs`**: includes the runtime compiler. - -:::tip NOTE -ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n(.runtime).node.mjs`. -::: diff --git a/packages/core/README.md b/packages/core/README.md index cbaff2059..df18111be 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -36,12 +36,6 @@ The intlify core module for i18n ### For Node.js (Server-Side) -- **`core.cjs(.prod).js`**: - - For CommonJS usage in Node.js - - For use in Node.js via `require()` - - If you bundle your app with webpack with `target: 'node'` and properly externalize `@intlify/core`, this is the build that will be loaded - - The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV` - - **`core(.runtime).node.mjs`**: - For ES Moudles usage in Node.js - For use in Node.js via `import` @@ -50,9 +44,6 @@ The intlify core module for i18n - **`core.runtime.node.mjs`**: is runtime only. proxy `core.runtime.mjs` - **`core.node.mjs`**: includes the runtime compiler. proxy `core.mjs` -> NOTE: ES Modules will be the future of the Node.js module system. The `core.cjs(.prod).js` will be deprecated in the future. We recommend you would use `core(.runtime).node.mjs`. 9.3+ - - ## :copyright: License [MIT](http://opensource.org/licenses/MIT) diff --git a/packages/vue-i18n/README.md b/packages/vue-i18n/README.md index 1a8dcadfb..db8b4d1cc 100644 --- a/packages/vue-i18n/README.md +++ b/packages/vue-i18n/README.md @@ -38,12 +38,6 @@ Internationalization plugin for Vue.js ### For Node.js (Server-Side) -- **`vue-i18n.cjs(.prod).js`**: - - For CommonJS usage in Node.js - - For use in Node.js via `require()` - - If you bundle your app with webpack with `target: 'node'` and properly externalize `vue-i18n`, this is the build that will be loaded - - The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV` - - **`vue-i18n(.runtime).node.mjs`**: - For ES Moudles usage in Node.js - For use in Node.js via `import` @@ -52,8 +46,6 @@ Internationalization plugin for Vue.js - **`vue-i18n.runtime.node.mjs`**: is runtime only - **`vue-i18n.node.mjs`**: includes the runtime compiler -> NOTE: ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n(.runtime).node.mjs`. 9.3+ - ## For Bundler feature flags From 925df2450346d0bd681085341d38944ad020c7d6 Mon Sep 17 00:00:00 2001 From: babu-ch Date: Sat, 15 Feb 2025 21:49:04 +0900 Subject: [PATCH 3/4] drop cjs: comment --- scripts/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ts b/scripts/build.ts index ff363d775..66e1bf15a 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -10,7 +10,7 @@ or "esm"): pnpm build core-base # specify the format to output -pnpm build core --formats esm +pnpm build core --formats mjs ``` */ From 5c725d40f2b882be2eb69ab3fa11c93e5251983e Mon Sep 17 00:00:00 2001 From: babu-ch Date: Mon, 17 Feb 2025 12:52:40 +0900 Subject: [PATCH 4/4] mjs to js --- docs/guide/extra/dist.md | 8 ++++---- packages/core-base/package.json | 10 +++++----- packages/core/README.md | 10 +++++----- packages/core/package.json | 10 +++++----- packages/devtools-types/package.json | 10 +++++----- packages/message-compiler/package.json | 10 +++++----- packages/petite-vue-i18n/package.json | 10 +++++----- packages/shared/package.json | 8 ++++---- packages/vue-i18n-core/package.json | 12 ++++++------ packages/vue-i18n/README.md | 10 +++++----- packages/vue-i18n/package.json | 10 +++++----- rollup.config.mjs | 12 ++++++------ scripts/rolldown.ts | 12 ++++++------ 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/docs/guide/extra/dist.md b/docs/guide/extra/dist.md index c82161aa9..be30b95ee 100644 --- a/docs/guide/extra/dist.md +++ b/docs/guide/extra/dist.md @@ -40,10 +40,10 @@ If you use `vue-i18n.runtime.esm-bundler.js`, you will need to precompile all lo ## For Node.js (Server-Side) -- **`vue-i18n(.runtime).node.mjs`**: +- **`vue-i18n(.runtime).node.js`**: - For ES Modules usage in Node.js - For use in Node.js via `import` - The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env``.NODE_ENV` - - This module is proxy module of `vue-i18n(.runtime).mjs` - - **`vue-i18n.runtime.node.mjs`**: is runtime only. - - **`vue-i18n.node.mjs`**: includes the runtime compiler. + - This module is proxy module of `vue-i18n(.runtime).js` + - **`vue-i18n.runtime.node.js`**: is runtime only. + - **`vue-i18n.node.js`**: includes the runtime compiler. diff --git a/packages/core-base/package.json b/packages/core-base/package.json index 8ac427ac3..a38568f6b 100644 --- a/packages/core-base/package.json +++ b/packages/core-base/package.json @@ -26,7 +26,7 @@ "files": [ "dist" ], - "module": "dist/core-base.mjs", + "module": "dist/core-base.js", "unpkg": "dist/core-base.global.js", "jsdelivr": "dist/core-base.global.js", "types": "dist/core-base.d.ts", @@ -51,13 +51,13 @@ "exports": { ".": { "types": "./dist/core-base.d.ts", - "import": "./dist/core-base.mjs", + "import": "./dist/core-base.js", "browser": "./dist/core-base.esm-browser.js", "node": { "import": { - "production": "./dist/core-base.prod.mjs", - "development": "./dist/core-base.mjs", - "default": "./dist/core-base.mjs" + "production": "./dist/core-base.prod.js", + "development": "./dist/core-base.js", + "default": "./dist/core-base.js" } } }, diff --git a/packages/core/README.md b/packages/core/README.md index df18111be..70975b72b 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -36,13 +36,13 @@ The intlify core module for i18n ### For Node.js (Server-Side) -- **`core(.runtime).node.mjs`**: - - For ES Moudles usage in Node.js +- **`core(.runtime).node.js`**: + - For ES Modules usage in Node.js - For use in Node.js via `import` - The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV` - - This module is proxy module of `core(.runtime).mjs` - - **`core.runtime.node.mjs`**: is runtime only. proxy `core.runtime.mjs` - - **`core.node.mjs`**: includes the runtime compiler. proxy `core.mjs` + - This module is proxy module of `core(.runtime).js` + - **`core.runtime.node.js`**: is runtime only. proxy `core.runtime.js` + - **`core.node.js`**: includes the runtime compiler. proxy `core.js` ## :copyright: License diff --git a/packages/core/package.json b/packages/core/package.json index 5c42d2d2a..cf03d284a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -26,7 +26,7 @@ "files": [ "dist" ], - "module": "dist/core.mjs", + "module": "dist/core.js", "unpkg": "dist/core.global.js", "jsdelivr": "dist/core.global.js", "types": "dist/core.d.ts", @@ -53,13 +53,13 @@ "exports": { ".": { "types": "./dist/core.d.ts", - "import": "./dist/core.mjs", + "import": "./dist/core.js", "browser": "./dist/core.esm-browser.js", "node": { "import": { - "production": "./dist/core.prod.node.mjs", - "development": "./dist/core.node.mjs", - "default": "./dist/core.node.mjs" + "production": "./dist/core.prod.node.js", + "development": "./dist/core.node.js", + "default": "./dist/core.node.js" } } }, diff --git a/packages/devtools-types/package.json b/packages/devtools-types/package.json index 5b9783fc9..dc4f6dcc3 100644 --- a/packages/devtools-types/package.json +++ b/packages/devtools-types/package.json @@ -25,7 +25,7 @@ "files": [ "dist" ], - "module": "dist/devtools-types.mjs", + "module": "dist/devtools-types.js", "types": "dist/devtools-types.d.ts", "dependencies": { "@intlify/core-base": "workspace:*", @@ -43,12 +43,12 @@ "exports": { ".": { "types": "./dist/devtools-types.d.ts", - "import": "./dist/devtools-types.mjs", + "import": "./dist/devtools-types.js", "node": { "import": { - "production": "./dist/devtools-types.prod.mjs", - "development": "./dist/devtools-types.mjs", - "default": "./dist/devtools-types.mjs" + "production": "./dist/devtools-types.prod.js", + "development": "./dist/devtools-types.js", + "default": "./dist/devtools-types.js" } } }, diff --git a/packages/message-compiler/package.json b/packages/message-compiler/package.json index 33d70c91c..60b444345 100644 --- a/packages/message-compiler/package.json +++ b/packages/message-compiler/package.json @@ -26,7 +26,7 @@ "files": [ "dist" ], - "module": "dist/message-compiler.mjs", + "module": "dist/message-compiler.js", "unpkg": "dist/message-compiler.global.js", "jsdelivr": "dist/message-compiler.global.js", "types": "dist/message-compiler.d.ts", @@ -50,13 +50,13 @@ "exports": { ".": { "types": "./dist/message-compiler.d.ts", - "import": "./dist/message-compiler.mjs", + "import": "./dist/message-compiler.js", "browser": "./dist/message-compiler.esm-browser.js", "node": { "import": { - "production": "./dist/message-compiler.node.mjs", - "development": "./dist/message-compiler.node.mjs", - "default": "./dist/message-compiler.node.mjs" + "production": "./dist/message-compiler.node.js", + "development": "./dist/message-compiler.node.js", + "default": "./dist/message-compiler.node.js" } } }, diff --git a/packages/petite-vue-i18n/package.json b/packages/petite-vue-i18n/package.json index ece619e68..4291425c6 100644 --- a/packages/petite-vue-i18n/package.json +++ b/packages/petite-vue-i18n/package.json @@ -28,7 +28,7 @@ "files": [ "dist" ], - "module": "dist/petite-vue-i18n.mjs", + "module": "dist/petite-vue-i18n.js", "unpkg": "dist/petite-vue-i18n.global.js", "jsdelivr": "dist/petite-vue-i18n.global.js", "types": "dist/petite-vue-i18n.d.ts", @@ -63,13 +63,13 @@ "exports": { ".": { "types": "./dist/petite-vue-i18n.d.ts", - "import": "./dist/petite-vue-i18n.mjs", + "import": "./dist/petite-vue-i18n.js", "browser": "./dist/petite-vue-i18n.esm-browser.js", "node": { "import": { - "production": "./dist/petite-vue-i18n.node.mjs", - "development": "./dist/petite-vue-i18n.node.mjs", - "default": "./dist/petite-vue-i18n.node.mjs" + "production": "./dist/petite-vue-i18n.node.js", + "development": "./dist/petite-vue-i18n.node.js", + "default": "./dist/petite-vue-i18n.node.js" } } }, diff --git a/packages/shared/package.json b/packages/shared/package.json index cc8dad5a6..9df8841ad 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -25,7 +25,7 @@ "files": [ "dist" ], - "module": "dist/shared.mjs", + "module": "dist/shared.js", "types": "dist/shared.d.ts", "engines": { "node": ">= 16" @@ -40,12 +40,12 @@ "exports": { ".": { "types": "./dist/shared.d.ts", - "import": "./dist/shared.mjs", + "import": "./dist/shared.js", "browser": "./dist/shared.esm-browser.js", "node": { "import": { - "development": "./dist/shared.mjs", - "default": "./dist/shared.mjs" + "development": "./dist/shared.js", + "default": "./dist/shared.js" } } }, diff --git a/packages/vue-i18n-core/package.json b/packages/vue-i18n-core/package.json index 3fe37f572..5a30c3c21 100644 --- a/packages/vue-i18n-core/package.json +++ b/packages/vue-i18n-core/package.json @@ -57,23 +57,23 @@ "exports": { ".": { "types": "./dist/vue-i18n-core.d.ts", - "import": "./dist/vue-i18n-core.mjs", + "import": "./dist/vue-i18n-core.js", "browser": "./dist/vue-i18n-core.esm-browser.js", "node": { "import": { - "development": "./dist/vue-i18n-core.mjs", - "default": "./dist/vue-i18n-core.mjs" + "development": "./dist/vue-i18n-core.js", + "default": "./dist/vue-i18n-core.js" } } }, "./petite": { "types": "./dist/petite-vue-i18n-core.d.ts", - "import": "./dist/petite-vue-i18n-core.mjs", + "import": "./dist/petite-vue-i18n-core.js", "browser": "./dist/petite-vue-i18n-core.esm-browser.js", "node": { "import": { - "development": "./petite-dist/vue-i18n-core.mjs", - "default": "./dist/petite-vue-i18n-core.mjs" + "development": "./petite-dist/vue-i18n-core.js", + "default": "./dist/petite-vue-i18n-core.js" } } }, diff --git a/packages/vue-i18n/README.md b/packages/vue-i18n/README.md index db8b4d1cc..02cffe254 100644 --- a/packages/vue-i18n/README.md +++ b/packages/vue-i18n/README.md @@ -38,13 +38,13 @@ Internationalization plugin for Vue.js ### For Node.js (Server-Side) -- **`vue-i18n(.runtime).node.mjs`**: - - For ES Moudles usage in Node.js +- **`vue-i18n(.runtime).node.js`**: + - For ES Modules usage in Node.js - For use in Node.js via `import` - The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV` - - This module is proxy module of `vue-i18n(.runtime).mjs` - - **`vue-i18n.runtime.node.mjs`**: is runtime only - - **`vue-i18n.node.mjs`**: includes the runtime compiler + - This module is proxy module of `vue-i18n(.runtime).js` + - **`vue-i18n.runtime.node.js`**: is runtime only + - **`vue-i18n.node.js`**: includes the runtime compiler ## For Bundler feature flags diff --git a/packages/vue-i18n/package.json b/packages/vue-i18n/package.json index 0c883d2b5..1467c77f2 100644 --- a/packages/vue-i18n/package.json +++ b/packages/vue-i18n/package.json @@ -28,7 +28,7 @@ "dist", "vetur" ], - "module": "dist/vue-i18n.mjs", + "module": "dist/vue-i18n.js", "unpkg": "dist/vue-i18n.global.js", "jsdelivr": "dist/vue-i18n.global.js", "types": "dist/vue-i18n.d.ts", @@ -63,13 +63,13 @@ "exports": { ".": { "types": "./dist/vue-i18n.d.ts", - "import": "./dist/vue-i18n.mjs", + "import": "./dist/vue-i18n.js", "browser": "./dist/vue-i18n.esm-browser.js", "node": { "import": { - "production": "./dist/vue-i18n.node.mjs", - "development": "./dist/vue-i18n.node.mjs", - "default": "./dist/vue-i18n.node.mjs" + "production": "./dist/vue-i18n.node.js", + "development": "./dist/vue-i18n.node.js", + "default": "./dist/vue-i18n.node.js" } } }, diff --git a/rollup.config.mjs b/rollup.config.mjs index 9231b59a2..296d1798e 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -34,19 +34,19 @@ let hasTSChecked = false function resolveStubs(name, ns = '') { return { - [`dist/${ns}${name}.mjs`]: `${ns}${name}.esm-bundler.js`, - [`dist/${ns}${name}.runtime.mjs`]: `${ns}${name}.runtime.esm-bundler.js`, + [`dist/${ns}${name}.js`]: `${ns}${name}.esm-bundler.js`, + [`dist/${ns}${name}.runtime.js`]: `${ns}${name}.runtime.esm-bundler.js`, } } function resolveOutputConfigs(name, ns = '') { return { mjs: { - file: `dist/${ns}${name}.mjs`, + file: `dist/${ns}${name}.js`, format: `es` }, 'mjs-node': { - file: `dist/${ns}${name}.node.mjs`, + file: `dist/${ns}${name}.node.js`, format: `es` }, browser: { @@ -59,11 +59,11 @@ function resolveOutputConfigs(name, ns = '') { }, // runtime-only builds, for '@intlify/core' and 'vue-i18n' package only 'mjs-runtime': { - file: `dist/${ns}${name}.runtime.mjs`, + file: `dist/${ns}${name}.runtime.js`, format: `es` }, 'mjs-node-runtime': { - file: `dist/${ns}${name}.runtime.node.mjs`, + file: `dist/${ns}${name}.runtime.node.js`, format: `es` }, 'browser-runtime': { diff --git a/scripts/rolldown.ts b/scripts/rolldown.ts index dedbf2381..9060faeb0 100644 --- a/scripts/rolldown.ts +++ b/scripts/rolldown.ts @@ -55,8 +55,8 @@ export function createConfigsForPackage({ function resolveStubs(name: string, ns = '') { return { - [`dist/${ns}${name}.mjs`]: `${ns}${name}.esm-bundler.js`, - [`dist/${ns}${name}.runtime.mjs`]: `${ns}${name}.runtime.esm-bundler.js` + [`dist/${ns}${name}.js`]: `${ns}${name}.esm-bundler.js`, + [`dist/${ns}${name}.runtime.js`]: `${ns}${name}.runtime.esm-bundler.js` } } @@ -66,11 +66,11 @@ export function createConfigsForPackage({ ): Record { return { mjs: { - file: resolve(`dist/${ns}${name}.mjs`), + file: resolve(`dist/${ns}${name}.js`), format: `es` }, 'mjs-node': { - file: resolve(`dist/${ns}${name}.node.mjs`), + file: resolve(`dist/${ns}${name}.node.js`), format: `es` }, browser: { @@ -83,11 +83,11 @@ export function createConfigsForPackage({ }, // runtime-only builds, for '@intlify/core' and 'vue-i18n' package only 'mjs-runtime': { - file: resolve(`dist/${ns}${name}.runtime.mjs`), + file: resolve(`dist/${ns}${name}.runtime.js`), format: `es` }, 'mjs-node-runtime': { - file: resolve(`dist/${ns}${name}.runtime.node.mjs`), + file: resolve(`dist/${ns}${name}.runtime.node.js`), format: `es` }, 'browser-runtime': {