Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
feat: support cjs and esm
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Nov 22, 2021
1 parent 09f614f commit 621baf0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
"type": "git",
"url": "https://github.com/storybookjs/testing-library.git"
},
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"license": "MIT",
"scripts": {
"build": "tsc",
"prepack": "npm run build"
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "tsc --project tsconfig.esm.json",
"build:cjs": "tsc --project tsconfig.cjs.json",
"prepack": "yarn build"
},
"files": [
"dist/**/*"
],
"types": "dist/index.d.ts",
"types": "dist/types/index.d.ts",
"publishConfig": {
"access": "public"
},
Expand All @@ -29,7 +32,6 @@
"devDependencies": {
"@storybook/linter-config": "^3.1.2",
"@types/react": "*",
"tsc": "^2.0.3",
"typescript": "^4.4.3"
}
}
5 changes: 2 additions & 3 deletions tsconfig.json → tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "CommonJS",
"target": "es5",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"declaration": true
"declaration": true,
"declarationDir": "./dist/types"
},
"include": ["src/*.ts"],
"exclude": ["node_modules"]
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"module": "CommonJS",
},
}
9 changes: 9 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/esm",
"module": "ES6",
"target": "ES5",
},
}

0 comments on commit 621baf0

Please sign in to comment.