Skip to content

Commit 05597cb

Browse files
authored
fix: fully cjs/esm dual pacakges (#222)
1 parent 1c70cc7 commit 05597cb

File tree

9 files changed

+1583
-34
lines changed

9 files changed

+1583
-34
lines changed

api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*
4646
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
4747
*/
48-
"mainEntryPointFilePath": "<projectFolder>/dist/cjs/index.d.ts",
48+
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
4949

5050
/**
5151
* A list of NPM package names whose exports should be treated as part of this package.

build.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig({
4+
declaration: true,
5+
outDir: 'dist',
6+
entries: [
7+
{
8+
name: 'index',
9+
input: 'src/index'
10+
}
11+
],
12+
rollup: {
13+
emitCJS: true
14+
}
15+
})

docs/@intlify/vue-i18n-extensions-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Transform `v-t` custom directive
1515

1616
**Signature:**
1717
```typescript
18-
export declare function transformVTDirective<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
18+
declare function transformVTDirective<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
1919
DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
2020
NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
2121
Legacy extends boolean = true>(options?: TransformVTDirectiveOptions<Messages, DateTimeFormats, NumberFormats, Legacy>): DirectiveTransform;
@@ -84,7 +84,7 @@ Transform options for `v-t` custom directive
8484

8585
**Signature:**
8686
```typescript
87-
export interface TransformVTDirectiveOptions<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
87+
interface TransformVTDirectiveOptions<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
8888
DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
8989
NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
9090
Legacy extends boolean = true>

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"tsx": "^4.11.0",
5454
"typescript": "^5.4.5",
5555
"typescript-eslint": "^7.9.0",
56+
"unbuild": "^2.0.0",
5657
"vitest": "^1.6.0",
5758
"vue": "^3.2.45"
5859
},
@@ -77,19 +78,22 @@
7778
}
7879
},
7980
"files": [
80-
"dist/cjs/*.js",
81-
"dist/esm/*.js",
82-
"dist/*.d.ts"
81+
"dist/idnex.cjs",
82+
"dist/index.mjs",
83+
"dist/index.d.ts",
84+
"dist/index.d.mts",
85+
"dist/index.d.cts"
8386
],
84-
"main": "dist/cjs/index.js",
85-
"module": "dist/esm/index.js",
86-
"types": "dist/vue-i18n-extensions.d.ts",
87+
"main": "dist/index.cjs",
88+
"module": "dist/index.mjs",
89+
"types": "dist/index.d.ts",
8790
"exports": {
8891
".": {
89-
"types": "./dist/vue-i18n-extensions.d.ts",
90-
"import": "./dist/esm/index.js",
91-
"require": "./dist/cjs/index.js"
92-
}
92+
"types": "./dist/index.d.ts",
93+
"import": "./dist/index.mjs",
94+
"require": "./dist/index.cjs"
95+
},
96+
"./package.json": "./package.json"
9397
},
9498
"repository": {
9599
"type": "git",
@@ -103,9 +107,7 @@
103107
"build:nightly": "pnpm build:transpile && pnpm build:extract",
104108
"build:docs": "api-docs-gen ./temp/vue-i18n-extensions.api.json -c ./docsgen.config.js -o ./docs",
105109
"build:extract": "api-extractor run -l -c ./api-extractor.json --typescript-compiler-folder node_modules/typescript",
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",
110+
"build:transpile": "unbuild",
109111
"check-install": "tsx scripts/playwright.ts",
110112
"clean": "git clean -fdx",
111113
"coverage": "opener coverage/lcov-report/index.html",

0 commit comments

Comments
 (0)