Skip to content

Commit

Permalink
Added double build for ESM and CJS
Browse files Browse the repository at this point in the history
  • Loading branch information
bring-shrubbery committed May 28, 2021
1 parent 2958a05 commit 9ba648b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 14 additions & 9 deletions package.json
@@ -1,19 +1,23 @@
{
"name": "use-cookie-consent",
"version": "0.1.6",
"version": "0.1.7",
"description": "React hook for managing GDPR cookie consent state.",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"main": "./build/cjs/index.js",
"types": "./build/cjs/index.d.ts",
"module": "./build/esm/index.js",
"files": [
"build/"
],
"scripts": {
"test": "jest --passWithNoTests",
"lint": "gts lint",
"clean": "gts clean",
"compile": "tsc",
"clean": "rimraf build",
"compile:esm": "tsc -p tsconfig.esm.json",
"compile:cjs": "tsc -p tsconfig.cjs.json",
"fix": "gts fix",
"prepare": "npm run compile",
"pretest": "npm run compile",
"prepare": "npm run build",
"posttest": "npm run lint",
"build": "npm run compile"
"build": "npm run compile:esm && npm run compile:cjs"
},
"keywords": [
"gdpr",
Expand All @@ -30,7 +34,7 @@
"url": "https://github.com/bring-shrubbery/use-cookie-consent/issues"
},
"author": {
"name": "Antoni Silvestrovic",
"name": "Antoni Silvestrovič",
"email": "antoni.silvestrovic@gmail.com",
"url": "http://antoni.ai/"
},
Expand All @@ -50,6 +54,7 @@
"prettier": "^2.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.1",
"typescript": "^4.2"
},
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
@@ -1,4 +1,2 @@
import {useCookieConsent} from './useCookieConsent';
export default useCookieConsent;
export * from './useCookieConsent';
export * from './types';
Object.assign(module.exports, useCookieConsent);
7 changes: 7 additions & 0 deletions tsconfig.cjs.json
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.esm.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./build/cjs"
},
}
13 changes: 6 additions & 7 deletions tsconfig.json → tsconfig.esm.json
@@ -1,16 +1,15 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
"module": "ESNext",
"target": "ES5",
"esModuleInterop": true,
"module": "ES2020",
"target": "ES2015",
"moduleResolution": "node",
"strict": true,
"declaration": true,
"rootDir": ".",
"outDir": "build",
"rootDir": "./src",
"outDir": "./build/esm",
"noImplicitAny": true,
"lib": ["es2016", "dom", "es5"]
},
"include": ["src/**/*.ts", "test/**/*.ts"],
"include": ["./src"],
"exclude": ["node_modules", "**/tests/*"]
}

0 comments on commit 9ba648b

Please sign in to comment.