-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor build system for ESM (#435)
* Refactor build system * Publish v7.0.0
- Loading branch information
Showing
22 changed files
with
255 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
node_modules | ||
*.log | ||
es6 | ||
esm | ||
cjs | ||
umd | ||
lib | ||
dist | ||
.DS_Store | ||
package-lock.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
node_modules | ||
*.log | ||
es6 | ||
esm | ||
cjs | ||
umd | ||
lib | ||
dist | ||
.DS_Store | ||
package-lock.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './es6'; | ||
export * from './esm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
{ | ||
"name": "react-cookie", | ||
"version": "6.1.3", | ||
"version": "7.0.0", | ||
"description": "Universal cookies for React", | ||
"main": "cjs/index.js", | ||
"module": "es6/index.js", | ||
"types": "es6/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./esm/index.mjs", | ||
"require": "./cjs/index.js" | ||
} | ||
}, | ||
"types": "esm/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"es6", | ||
"esm", | ||
"cjs", | ||
"umd", | ||
"lib", | ||
"index.d.ts", | ||
"LICENSE" | ||
], | ||
|
@@ -29,17 +33,14 @@ | |
"author": "Benoit Tremblay <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rimraf lib && rimraf es6 && rimraf cjs && rimraf umd", | ||
"build": "npm run clean && npm run build-es6 && npm run build-cjs && npm run build-umd && npm run build-legacy", | ||
"build-es6": "tsc", | ||
"build-cjs": "babel es6 -D -d cjs", | ||
"build-umd": "rollup -c", | ||
"build-legacy": "babel es6 -D -d lib" | ||
"prebuild": "rimraf esm && rimraf cjs && rimraf umd", | ||
"build": "rollup -c", | ||
"postbuild": "rimraf -G {cjs,umd}/*.d.ts" | ||
}, | ||
"dependencies": { | ||
"@types/hoist-non-react-statics": "^3.3.5", | ||
"hoist-non-react-statics": "^3.3.2", | ||
"universal-cookie": "^6.0.0" | ||
"universal-cookie": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.23.4", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import glob from 'glob'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
|
||
export default { | ||
input: Object.fromEntries( | ||
glob | ||
.sync('src/**/*.{ts,tsx}') | ||
.map((file) => [ | ||
path.relative( | ||
'src', | ||
file.slice(0, file.length - path.extname(file).length), | ||
), | ||
fileURLToPath(new URL(file, import.meta.url)), | ||
]), | ||
), | ||
output: { | ||
dir: './esm', | ||
format: 'esm', | ||
entryFileNames: '[name].mjs', | ||
}, | ||
plugins: [typescript()], | ||
external: ['react', 'universal-cookie', 'hoist-non-react-statics'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
{ | ||
"name": "universal-cookie-express", | ||
"version": "6.1.3", | ||
"version": "7.0.0", | ||
"description": "Hook cookies get/set on Express for server-rendering", | ||
"main": "cjs/index.js", | ||
"module": "es6/index.js", | ||
"types": "es6/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./esm/index.mjs", | ||
"require": "./cjs/index.js" | ||
} | ||
}, | ||
"types": "esm/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"lib", | ||
"es6", | ||
"esm", | ||
"cjs", | ||
"LICENSE" | ||
], | ||
|
@@ -27,14 +31,12 @@ | |
"author": "Benoit Tremblay <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rimraf lib && rimraf es6 && rimraf cjs", | ||
"build": "npm run clean && npm run build-es6 && npm run build-cjs && npm run build-legacy", | ||
"build-es6": "tsc", | ||
"build-cjs": "babel es6 -D -d cjs", | ||
"build-legacy": "babel es6 -D -d lib" | ||
"prebuild": "rimraf esm && rimraf cjs", | ||
"build": "rollup -c", | ||
"postbuild": "rimraf -G cjs/*.d.ts" | ||
}, | ||
"dependencies": { | ||
"universal-cookie": "^6.0.0" | ||
"universal-cookie": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.23.4", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import typescript from '@rollup/plugin-typescript'; | ||
import babel from '@rollup/plugin-babel'; | ||
|
||
const external = ['react', 'universal-cookie']; | ||
const globals = { | ||
react: 'React', | ||
'universal-cookie': 'UniversalCookie', | ||
}; | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.ts', | ||
output: { | ||
dir: './esm', | ||
format: 'esm', | ||
entryFileNames: '[name].mjs', | ||
}, | ||
plugins: [typescript({ outDir: './esm' })], | ||
external, | ||
}, | ||
{ | ||
input: 'src/index.ts', | ||
output: { | ||
dir: './cjs', | ||
format: 'cjs', | ||
}, | ||
plugins: [ | ||
typescript({ outDir: './cjs' }), | ||
babel({ babelHelpers: 'bundled' }), | ||
], | ||
external, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
{ | ||
"name": "universal-cookie-koa", | ||
"version": "6.1.3", | ||
"version": "7.0.0", | ||
"description": "Hook cookies get/set on Koa for server-rendering", | ||
"main": "cjs/index.js", | ||
"module": "es6/index.js", | ||
"types": "es6/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./esm/index.mjs", | ||
"require": "./cjs/index.js" | ||
} | ||
}, | ||
"types": "esm/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"lib", | ||
"es6", | ||
"esm", | ||
"cjs", | ||
"LICENSE" | ||
], | ||
|
@@ -27,14 +31,12 @@ | |
"author": "Benoit Tremblay <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rimraf lib && rimraf es6 && rimraf cjs", | ||
"build": "npm run clean && npm run build-es6 && npm run build-cjs && npm run build-legacy", | ||
"build-es6": "tsc", | ||
"build-cjs": "babel es6 -D -d cjs", | ||
"build-legacy": "babel es6 -D -d lib" | ||
"prebuild": "rimraf esm && rimraf cjs", | ||
"build": "rollup -c", | ||
"postbuild": "rimraf -G cjs/*.d.ts" | ||
}, | ||
"dependencies": { | ||
"universal-cookie": "^6.0.0" | ||
"universal-cookie": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.23.4", | ||
|
Oops, something went wrong.