Skip to content

Commit 05bb19e

Browse files
authored
fix: cjs/esm dual packages (#221)
* fix: cjs/esm dual packages * fix * fix: esm build error * fix * fix
1 parent 015fb15 commit 05bb19e

File tree

8 files changed

+425
-396
lines changed

8 files changed

+425
-396
lines changed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ __snapshots__
77
test
88
etc
99
dist/*.json
10+
dist/cjs/*.d.ts
11+
dist/esm/*.d.ts
1012
temp/

api-extractor.json

Lines changed: 364 additions & 364 deletions
Large diffs are not rendered by default.

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"devDependencies": {
1616
"@vitejs/plugin-vue": "^5.0.4",
17+
"@intlify/vue-i18n-extensions": "workspace:*",
1718
"typescript": "^5.0.2",
1819
"vite": "^5.2.11",
1920
"vue-tsc": "^2.0.17"

example/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import vue from '@vitejs/plugin-vue'
33
// import vueJsx from '@vitejs/plugin-vue-jsx'
44
// import vueI18n from '@intlify/unplugin-vue-i18n/vite'
55
// import bodyParser from 'body-parser'
6-
import { transformVTDirective } from '../lib/index'
6+
import { transformVTDirective } from '@intlify/vue-i18n-extensions'
77
// import { transformVTDirective } from '@intlify/vue-i18n-extensions'
88

99
/**

package.json

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
"bugs": {
1010
"url": "https://github.com/intlify/vue-i18n-extensions/issues"
1111
},
12+
"homepage": "https://github.com/intlify/vue-i18n-extensions#readme",
13+
"keywords": [
14+
"extensions",
15+
"i18n",
16+
"optimaization",
17+
"server-side-rendering",
18+
"vue",
19+
"vue-i18n"
20+
],
21+
"license": "MIT",
1222
"dependencies": {
1323
"@babel/parser": "^7.24.6",
1424
"@intlify/shared": "^9.0.0",
@@ -66,37 +76,21 @@
6676
"optional": true
6777
}
6878
},
69-
"engines": {
70-
"node": ">= 18"
71-
},
7279
"files": [
73-
"lib/*.js",
80+
"dist/cjs/*.js",
81+
"dist/esm/*.js",
7482
"dist/*.d.ts"
7583
],
76-
"homepage": "https://github.com/intlify/vue-i18n-extensions#readme",
77-
"keywords": [
78-
"extensions",
79-
"i18n",
80-
"optimaization",
81-
"server-side-rendering",
82-
"vue",
83-
"vue-i18n"
84-
],
85-
"license": "MIT",
86-
"lint-staged": {
87-
"*.{json,md,yml}": [
88-
"prettier --write"
89-
],
90-
"*.{js,mjs,cjs}": [
91-
"prettier --write",
92-
"eslint --fix"
93-
],
94-
"*.ts?(x)": [
95-
"prettier --parser=typescript --write",
96-
"eslint --fix"
97-
]
84+
"main": "dist/cjs/index.js",
85+
"module": "dist/esm/index.js",
86+
"types": "dist/vue-i18n-extensions.d.ts",
87+
"exports": {
88+
".": {
89+
"types": "./dist/vue-i18n-extensions.d.ts",
90+
"import": "./dist/esm/index.js",
91+
"require": "./dist/cjs/index.js"
92+
}
9893
},
99-
"main": "lib/index.js",
10094
"repository": {
10195
"type": "git",
10296
"url": "git+https://github.com/intlify/vue-i18n-extensions.git"
@@ -109,7 +103,9 @@
109103
"build:nightly": "pnpm build:transpile && pnpm build:extract",
110104
"build:docs": "api-docs-gen ./temp/vue-i18n-extensions.api.json -c ./docsgen.config.js -o ./docs",
111105
"build:extract": "api-extractor run -l -c ./api-extractor.json --typescript-compiler-folder node_modules/typescript",
112-
"build:transpile": "tsc -p tsconfig.build.json",
106+
"build:transpile": "run-s build:transpile:*",
107+
"build:transpile:cjs": "tsc -p tsconfig.cjs.json",
108+
"build:transpile:esm": "tsc -p tsconfig.esm.json",
113109
"check-install": "tsx scripts/playwright.ts",
114110
"clean": "git clean -fdx",
115111
"coverage": "opener coverage/lcov-report/index.html",
@@ -125,8 +121,23 @@
125121
"test:e2e": "vitest -c ./vitest.e2e.config.ts run",
126122
"test:unit": "vitest run",
127123
"test:watch": "vitest --no-cache --watch",
128-
"watch": "tsc -p tsconfig.build.json --watch"
124+
"watch": "tsc -p tsconfig.cjs.json --watch"
129125
},
130-
"types": "dist/vue-i18n-extensions.d.ts",
131-
"packageManager": "[email protected]"
126+
"packageManager": "[email protected]",
127+
"engines": {
128+
"node": ">= 18"
129+
},
130+
"lint-staged": {
131+
"*.{json,md,yml}": [
132+
"prettier --write"
133+
],
134+
"*.{js,mjs,cjs}": [
135+
"prettier --write",
136+
"eslint --fix"
137+
],
138+
"*.ts?(x)": [
139+
"prettier --parser=typescript --write",
140+
"eslint --fix"
141+
]
142+
}
132143
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./dist/cjs"
5+
},
36
"include": ["./src/**/*"]
47
}

tsconfig.esm.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./dist/esm",
5+
"module": "esnext",
6+
"moduleResolution": "Bundler"
7+
},
8+
"include": ["./src/**/*"]
9+
}

0 commit comments

Comments
 (0)