Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): use *.d.mts for esm ('import' condition only) #581

Merged
merged 1 commit into from
Oct 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 23 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,48 @@
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./esm/index.d.mts",
"default": "./esm/index.mjs"
},
"types": "./index.d.ts",
"module": "./esm/index.js",
"import": "./esm/index.mjs",
"default": "./index.js"
},
"./vanilla": {
"import": {
"types": "./esm/vanilla.d.mts",
"default": "./esm/vanilla.mjs"
},
"types": "./vanilla.d.ts",
"module": "./esm/vanilla.js",
"import": "./esm/vanilla.mjs",
"default": "./vanilla.js"
},
"./utils": {
"import": {
"types": "./esm/utils.d.mts",
"default": "./esm/utils.mjs"
},
"types": "./utils.d.ts",
"module": "./esm/utils.js",
"import": "./esm/utils.mjs",
"default": "./utils.js"
},
"./macro": {
"import": {
"types": "./esm/macro.d.mts",
"default": "./esm/macro.mjs"
},
"types": "./macro.d.ts",
"module": "./esm/macro.js",
"import": "./esm/macro.mjs",
"default": "./macro.js"
},
"./macro/vite": {
"import": {
"types": "./esm/macro/vite.d.mts",
"default": "./esm/macro/vite.mjs"
},
"types": "./esm/macro/vite.d.ts",
"module": "./esm/macro/vite.js",
"import": "./esm/macro/vite.mjs",
"default": "./macro/vite.js"
}
},
Expand All @@ -61,7 +76,7 @@
"build:utils": "rollup -c --config-utils",
"build:macro": "rollup -c --config-macro",
"build:macro-vite": "rollup -c --config-macro_vite",
"postbuild": "yarn copy && yarn patch-macro-vite && yarn patch-ts3.4",
"postbuild": "yarn copy && yarn patch-macro-vite && yarn patch-ts3.4 && yarn patch-esm-ts",
"prettier": "prettier '*.{js,json,md}' '{src,tests,docs}/**/*.{ts,tsx,md,mdx}' --write",
"prettier:ci": "prettier '*.{js,json,md}' '{src,tests,docs}/**/*.{ts,tsx,md,mdx}' --list-different",
"eslint": "eslint --fix '*.{js,json}' '{src,tests}/**/*.{ts,tsx}'",
Expand All @@ -73,7 +88,8 @@
"test:coverage:watch": "jest --watch",
"copy": "shx cp -r dist/src/* dist/esm && shx mv dist/src/* dist && shx rm -rf dist/{src,tests} && downlevel-dts dist dist/ts3.4 && shx cp package.json readme.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.prettier=undefined; this.jest=undefined;\"",
"patch-macro-vite": "shx cp dist/esm/macro/vite.d.ts dist/macro/ && shx mkdir dist/ts3.4/macro && shx cp dist/ts3.4/esm/macro/vite.d.ts dist/ts3.4/macro/",
"patch-ts3.4": "node -e \"require('shelljs').find('dist/ts3.4/**/*.d.ts').forEach(f=>require('fs').appendFileSync(f,'declare type Awaited<T> = T extends Promise<infer V> ? V : T;'))\"; shx sed -i 's/^declare type Snapshot<T> =/declare type Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<any> ? Awaited<T> : { readonly [K in keyof T]: Snapshot2<T[K]> }; type Snapshot2<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<any> ? Awaited<T> : { readonly [K in keyof T]: T[K] };declare type _Snapshot<T> =/' 'dist/ts3.4/**/*.d.ts'"
"patch-ts3.4": "node -e \"require('shelljs').find('dist/ts3.4/**/*.d.ts').forEach(f=>require('fs').appendFileSync(f,'declare type Awaited<T> = T extends Promise<infer V> ? V : T;'))\"; shx sed -i 's/^declare type Snapshot<T> =/declare type Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<any> ? Awaited<T> : { readonly [K in keyof T]: Snapshot2<T[K]> }; type Snapshot2<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<any> ? Awaited<T> : { readonly [K in keyof T]: T[K] };declare type _Snapshot<T> =/' 'dist/ts3.4/**/*.d.ts'",
"patch-esm-ts": "node -e \"require('shelljs').find('dist/esm/**/*.d.ts').forEach(f=>require('fs').copyFileSync(f,f.replace(/\\.ts$/,'.mts')))\"; shx sed -i \"s/ from '(\\..*)';$/ from '\\$1.mjs';/\" 'dist/esm/**/*.d.mts'; shx sed -i \"s/^declare module '(\\..*)'/declare module '\\$1.mjs'/\" 'dist/esm/**/*.d.mts'"
},
"engines": {
"node": ">=12.7.0"
Expand Down