-
Notifications
You must be signed in to change notification settings - Fork 1
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: dual build to emit both commonJS and ESM to maximize compatibility #31
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"name": "@optum/react-hooks", | ||
"version": "1.0.2-next.1", | ||
"version": "1.0.2-next.2", | ||
"description": "A reusable set of React hooks", | ||
"repository": "https://github.com/Optum/react-hooks", | ||
"license": "Apache 2.0", | ||
"main": "build/lib/es5/index.js", | ||
"module": "build/lib/es6/index.js", | ||
Comment on lines
+7
to
+8
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. Can we leave |
||
"sideEffects": false, | ||
"scripts": { | ||
"build": "tsc --project tsconfig.json", | ||
"build": "rm -rf build/lib && tsc && tsc --build tsconfig.es5.json", | ||
"prepack": "yarn build" | ||
}, | ||
"files": [ | ||
|
@@ -36,19 +38,6 @@ | |
"dependencies": { | ||
"tslib": "^2.3.1" | ||
}, | ||
"exports": { | ||
".": { | ||
"require": { | ||
"types": "./build/types/cjs/index.d.ts", | ||
"default": "./build/cjs/index.js" | ||
}, | ||
"types": "./build/types/cjs/index.d.ts", | ||
"default": "./build/cjs/index.js" | ||
} | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"stableVersion": "1.8.0-next.245", | ||
"packageManager": "yarn@3.6.1" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
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. Can we use one |
||
"module": "CommonJS", | ||
"target": "ES5", | ||
"lib": ["ES2020", "DOM"], | ||
"declaration": true, | ||
"outDir": "./build/lib/es5", | ||
"moduleResolution":"Node", | ||
"preserveSymlinks": true, | ||
"rootDir": ".", | ||
"sourceMap": true, | ||
"strict": true, | ||
"noImplicitReturns": true, | ||
"importHelpers": true, | ||
"noEmitHelpers": true, | ||
"noUnusedLocals": true, | ||
"jsx": "preserve", | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["**/*.ts", "**/*.tsx"] | ||
} | ||
|
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.
@nthurow These changes make the build come together - commonJS projects will reference "main" whereas ESM projects refer to "module"
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.
But the "module" field isn't official, it's not even really documented anywhere. The "exports" field (along with the "require" and "import" conditions) is the official way to handle a dual build. So that's why what I'm thinking is, can we leave the "main" field here but add back the "exports" field (and make sure to include both "require" and "import" conditions)? The "main" field might solve some of the legacy issues that we are encountering with the SCL and tst-scl, and the "exports" field should still enable the dual-build.