Skip to content

Commit 27ec73f

Browse files
authored
feat!: move packages to ESM first (#418)
1 parent 1e3abe8 commit 27ec73f

File tree

6 files changed

+76
-30
lines changed

6 files changed

+76
-30
lines changed

packages/bundle-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@intlify/bundle-utils",
3+
"type": "module",
34
"description": "Bundle utilities for Intlify project",
45
"version": "9.0.0",
56
"author": {
@@ -47,7 +48,6 @@
4748
"types": "lib/index.d.ts",
4849
"exports": {
4950
".": {
50-
"types": "./lib/index.d.ts",
5151
"import": "./lib/index.mjs",
5252
"require": "./lib/index.cjs"
5353
},

packages/bundle-utils/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// "incremental": true, /* Enable incremental compilation */
77
"target": "es2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
88
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9-
// "lib": [], /* Specify library files to be included in the compilation. */
9+
"lib": ["esnext"], /* Specify library files to be included in the compilation. */
1010
// "allowJs": true, /* Allow javascript files to be compiled. */
1111
// "checkJs": true, /* Report errors in .js files. */
1212
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */

packages/unplugin-vue-i18n/build.config.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import { readFile, rm, writeFile } from 'node:fs/promises'
2+
import { fileURLToPath } from 'node:url'
3+
import { resolve } from 'node:path'
14
import { defineBuildConfig } from 'unbuild'
25

6+
const lib = fileURLToPath(new URL('./lib', import.meta.url))
7+
38
export default defineBuildConfig({
49
declaration: true,
510
outDir: 'lib',
@@ -24,5 +29,27 @@ export default defineBuildConfig({
2429
rollup: {
2530
emitCJS: true
2631
},
27-
externals: ['vite', 'webpack']
32+
externals: ['vite', 'webpack'],
33+
hooks: {
34+
'build:done': async () => {
35+
await Promise.all([
36+
rm(resolve(lib, 'types.cjs')),
37+
rm(resolve(lib, 'types.mjs')),
38+
...['vite', 'webpack'].map(async name => {
39+
for (const ext of ['d.ts', 'd.cts']) {
40+
const path = resolve(lib, `${name}.${ext}`)
41+
const content = await readFile(path, 'utf-8')
42+
await writeFile(
43+
path,
44+
content.replace(
45+
`export { ${name} as default };`,
46+
`export = ${name};`
47+
),
48+
{ encoding: 'utf-8' }
49+
)
50+
}
51+
})
52+
])
53+
}
54+
}
2855
})

packages/unplugin-vue-i18n/package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@intlify/unplugin-vue-i18n",
3+
"type": "module",
34
"version": "5.3.1",
45
"description": "unplugin for Vue I18n",
56
"author": {
@@ -41,7 +42,8 @@
4142
"vue": "^3.4"
4243
},
4344
"devDependencies": {
44-
"unbuild": "^2.0.0"
45+
"unbuild": "^2.0.0",
46+
"@types/node": "^20.14.8"
4547
},
4648
"engines": {
4749
"node": ">= 18"
@@ -67,22 +69,24 @@
6769
"types": "./index.d.ts",
6870
"exports": {
6971
".": {
70-
"types": "./index.d.ts",
71-
"require": "./lib/index.cjs",
72-
"import": "./lib/index.mjs"
72+
"import": "./lib/index.mjs",
73+
"require": "./lib/index.cjs"
7374
},
7475
"./vite": {
75-
"types": "./vite.d.ts",
76-
"require": "./lib/vite.cjs",
77-
"import": "./lib/vite.mjs"
76+
"import": "./lib/vite.mjs",
77+
"require": "./lib/vite.cjs"
7878
},
7979
"./webpack": {
80-
"types": "./webpack.d.ts",
81-
"require": "./lib/webpack.cjs",
82-
"import": "./lib/webpack.mjs"
80+
"import": "./lib/webpack.mjs",
81+
"require": "./lib/webpack.cjs"
8382
},
8483
"./types": {
85-
"types": "./types.d.ts"
84+
"import": {
85+
"types": "./lib/types.d.mts"
86+
},
87+
"require": {
88+
"types": "./lib/types.d.cts"
89+
}
8690
},
8791
"./messages": {
8892
"types": "./messages.d.ts"

packages/unplugin-vue-i18n/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// "incremental": true, /* Enable incremental compilation */
77
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
88
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9-
// "lib": [], /* Specify library files to be included in the compilation. */
9+
"lib": ["esnext"], /* Specify library files to be included in the compilation. */
1010
// "allowJs": true, /* Allow javascript files to be compiled. */
1111
// "checkJs": true, /* Report errors in .js files. */
1212
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */

pnpm-lock.yaml

Lines changed: 30 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)