Skip to content

Commit

Permalink
feat: dual build to emit both commonJS and ESM to maximize compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsJPeschel committed Apr 3, 2024
1 parent e710df2 commit 1d2a199
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
19 changes: 4 additions & 15 deletions package.json
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",
"sideEffects": false,
"scripts": {
"build": "tsc --project tsconfig.json",
"build": "rm -rf build/lib && tsc && tsc --build tsconfig.es5.json",
"prepack": "yarn build"
},
"files": [
Expand Down Expand Up @@ -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": "[email protected]"
}
28 changes: 28 additions & 0 deletions tsconfig.es5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"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"]
}

14 changes: 7 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"module": "Node16",
"moduleResolution":"Node16",
"module": "ES6",
"target": "ES5",
"lib": ["ES2020", "DOM"],
"declaration": true,
"outDir": "./build/lib/es6",
"moduleResolution":"Node",
"preserveSymlinks": true,
"rootDir": ".",
"outDir": "build/cjs",
"declaration": true,
"declarationDir": "build/types/cjs",
"target": "ES6",
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
Expand All @@ -22,6 +22,6 @@
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": ["node_modules"],
"exclude": ["node_modules", "!node_modules/@types"],
"include": ["**/*.ts", "**/*.tsx"]
}

0 comments on commit 1d2a199

Please sign in to comment.