Skip to content

Commit 6536ac0

Browse files
committed
Build for both commonjs & ES modules
1 parent 7ec4612 commit 6536ac0

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
"name": "react-reverse-portal",
33
"version": "0.1.0",
44
"description": "Build an element once, move it anywhere",
5-
"main": "dist/index.js",
5+
"main": "dist/cjs/index.js",
6+
"module": "dist/esm/index.js",
67
"types": "dist/index.d.ts",
78
"files": [
8-
"dist/",
9-
"src/",
9+
"dist/**/*.{js,ts,map}",
10+
"src/**/*",
1011
"README.md"
1112
],
1213
"scripts": {
13-
"build": "tsc",
14+
"build": "rimraf dist/ && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
1415
"pretest": "npm run build",
15-
"test": "echo \"It built ok, that'll do for now\""
16+
"test": "echo \"It built ok, that'll do for now\"",
17+
"prepack": "npm run build"
1618
},
1719
"repository": {
1820
"type": "git",
@@ -38,6 +40,7 @@
3840
"@types/react-dom": "^16.9.0",
3941
"react": "^16.9.0",
4042
"react-dom": "^16.9.0",
43+
"rimraf": "^3.0.0",
4144
"typescript": "^3.5.3"
4245
},
4346
"peerDependencies": {

tsconfig.cjs.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./dist/cjs"
6+
}
7+
}

tsconfig.esm.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "es6",
5+
"outDir": "./dist/esm"
6+
}
7+
}

tsconfig.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"compilerOptions": {
3-
"target": "es2015",
4-
"module": "commonjs",
5-
"moduleResolution": "node",
6-
"outDir": "./dist",
7-
"sourceMap": true,
8-
"jsx": "react",
9-
"strict": true,
10-
"declaration": true
11-
},
12-
"include": [
13-
"./src/**/*.tsx"
14-
]
2+
"compilerOptions": {
3+
"target": "es2015",
4+
"composite": true,
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"jsx": "react",
8+
"strict": true,
9+
"rootDir": "./src",
10+
"declaration": true,
11+
"declarationDir": "./dist"
12+
},
13+
"include": [
14+
"./src/**/*.tsx"
15+
]
1516
}

0 commit comments

Comments
 (0)