-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat!: move to ESM first with dual ESM/CJS subpackage exports #881
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c4f08b
feat!: move to ESM first with dual ESM/CJS subpackage exports
userquin 8f3c17e
chore: fix CI
userquin 6677d5c
chore: .
userquin 1566465
chore: .
userquin afa339e
chore: fix test
userquin 972d7e6
chore: fix CI 3
userquin ed28686
chore: fix CI 4
userquin 26b9337
Merge branch 'refs/heads/main' into feat-esm-first
userquin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,67 @@ | ||
{ | ||
"name": "valtio", | ||
"type": "module", | ||
"private": true, | ||
"version": "1.13.2", | ||
"description": "💊 Valtio makes proxy-state simple for React and Vanilla", | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
"typesVersions": { | ||
"<4.5": { | ||
"esm/*": [ | ||
"ts3.4/*" | ||
], | ||
"*": [ | ||
"ts3.4/*" | ||
] | ||
} | ||
}, | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"import": { | ||
"types": "./esm/index.d.mts", | ||
"default": "./esm/index.mjs" | ||
}, | ||
"module": { | ||
"types": "./esm/index.d.ts", | ||
"default": "./esm/index.js" | ||
}, | ||
"default": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
} | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"./macro": { | ||
"import": "./dist/macro.mjs", | ||
"require": "./dist/macro.cjs" | ||
}, | ||
"./macro/vite": { | ||
"import": "./dist/macro/vite.mjs", | ||
"require": "./dist/macro/vite.cjs" | ||
}, | ||
"./react": { | ||
"import": "./dist/react.mjs", | ||
"require": "./dist/react.cjs" | ||
}, | ||
"./react/utils": { | ||
"import": "./dist/react/utils.mjs", | ||
"require": "./dist/react/utils.cjs" | ||
}, | ||
"./utils": { | ||
"import": "./dist/utils.mjs", | ||
"require": "./dist/utils.cjs" | ||
}, | ||
"./vanilla": { | ||
"import": "./dist/vanilla.mjs", | ||
"require": "./dist/vanilla.cjs" | ||
}, | ||
"./vanilla/utils": { | ||
"import": "./dist/vanilla/utils.mjs", | ||
"require": "./dist/vanilla/utils.cjs" | ||
} | ||
}, | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"typesVersions": { | ||
"<4.5": { | ||
"macro": ["./dist/ts3.4/macro.d.ts"], | ||
"macro/vite": ["./dist/ts3.4/macro/vite.d.ts"], | ||
"react": ["./dist/ts3.4/react.d.ts"], | ||
"react/utils": ["./dist/ts3.4/react/utils.d.ts"], | ||
"utils": ["./dist/ts3.4/utils.d.ts"], | ||
"vanilla": ["./dist/ts3.4/vanilla.d.ts"], | ||
"vanilla/utils": ["./dist/ts3.4/vanilla/utils.d.ts"], | ||
"*": ["./dist/ts3.4/*"] | ||
}, | ||
"./*": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious why we need to avoid subpath patterns? |
||
"import": { | ||
"types": "./esm/*.d.mts", | ||
"default": "./esm/*.mjs" | ||
}, | ||
"module": { | ||
"types": "./esm/*.d.ts", | ||
"default": "./esm/*.js" | ||
}, | ||
"default": { | ||
"types": "./*.d.ts", | ||
"default": "./*.js" | ||
} | ||
">=4.5": { | ||
"macro": ["./dist/macro.d.ts"], | ||
"macro/vite": ["./dist/macro/vite.d.ts"], | ||
"react": ["./dist/react.d.ts"], | ||
"react/utils": ["./dist/react/utils.d.ts"], | ||
"utils": ["./dist/utils.d.ts"], | ||
"vanilla": ["./dist/vanilla.d.ts"], | ||
"vanilla/utils": ["./dist/vanilla/utils.d.ts"], | ||
"*": ["./*"] | ||
} | ||
}, | ||
"files": [ | ||
|
@@ -52,17 +70,18 @@ | |
"sideEffects": false, | ||
"scripts": { | ||
"prebuild": "shx rm -rf dist", | ||
"build": "concurrently -m 8 'yarn:build:*'", | ||
"build": "rollup -c --config-all && node scripts/patch-dts.mjs", | ||
"old-build": "concurrently -m 8 'yarn:build:*'", | ||
"build-watch": "concurrently -n watch: 'yarn:build:* --watch'", | ||
"build:base": "rollup -c", | ||
"build:utils": "rollup -c --config-utils", | ||
"build:vanilla": "rollup -c --config-vanilla", | ||
"build:vanilla_utils": "rollup -c --config-vanilla_utils", | ||
"build:react": "rollup -c --config-react", | ||
"build:react_utils": "rollup -c --config-react_utils", | ||
"build:macro": "rollup -c --config-macro", | ||
"build:macro_vite": "rollup -c --config-macro_vite", | ||
"postbuild": "yarn patch-d-ts && yarn copy && yarn patch-macro-vite && yarn patch-ts3.4 && yarn patch-esm-ts", | ||
"postbuild": "yarn copy", | ||
"xpostbuild": "yarn patch-d-ts && 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 --no-eslintrc --c .eslintrc.json --fix '*.{js,json,ts}' '{src,tests}/**/*.{ts,tsx}'", | ||
|
@@ -71,7 +90,8 @@ | |
"test": "vitest --ui --coverage", | ||
"test:ci": "vitest", | ||
"patch-d-ts": "node -e \"var {entries}=require('./rollup.config.js');require('shelljs').find('dist/**/*.d.ts').forEach(f=>{entries.forEach(({find,replacement})=>require('shelljs').sed('-i',new RegExp(' from \\''+find.source.slice(0,-1)+'\\';$'),' from \\''+replacement+'\\';',f));require('shelljs').sed('-i',/ from '(\\.[^']+)\\.ts';$/,' from \\'\\$1\\';',f)})\"", | ||
"copy": "shx cp -r dist/src/* dist/esm && shx cp -r 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;\"", | ||
"copy": "shx mkdir dist/esm && shx cp -r src/* dist/esm && shx rm -rf dist/{src,tests} && 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;\"", | ||
"xcopy": "shx cp -r dist/src/* dist/esm && shx cp -r 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;\"", | ||
"patch-macro-vite": "shx cp dist/esm/macro/vite.d.ts dist/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;');require('shelljs').sed('-i',/^declare type Snapshot<T> =/,'declare type Snapshot<T> = T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { readonly [K in keyof T]: Snapshot2<T[K]> } : T; declare type Snapshot2<T> = T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { readonly [K in keyof T]: T[K] } : T;;declare type _Snapshot<T> =',f)})\"", | ||
"patch-esm-ts": "node -e \"require('shelljs').find('dist/esm/**/*.d.ts').forEach(f=>{var f2=f.replace(/\\.ts$/,'.mts');require('fs').copyFileSync(f,f2);require('shelljs').sed('-i',/ from '(\\.[^']+)';$/,' from \\'\\$1.mjs\\';',f2);require('shelljs').sed('-i',/^declare module '(\\.[^']+)'/,'declare module \\'\\$1.mjs\\'',f2)})\"" | ||
|
@@ -156,6 +176,7 @@ | |
"react-dom": "^18.2.0", | ||
"redux": "^5.0.1", | ||
"rollup": "^4.12.0", | ||
"rollup-plugin-dts": "^6.1.0", | ||
"rollup-plugin-esbuild": "^6.1.1", | ||
"shx": "^0.3.4", | ||
"ts-expect": "^1.3.0", | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh, unfortunately, this is not acceptable. we try to keep cjs first. we plan esm first for valtio v3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr is for main, I can send another pr using commonjs to v2 branch (this PR should be closed)