Skip to content

Commit

Permalink
Merge pull request #613 from reduxjs/feature/5.0-browser-artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson authored May 14, 2023
2 parents 1a85288 + 3318bf2 commit 88c4638
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "5.0.0-alpha.1",
"description": "Selectors for Redux.",
"main": "./dist/cjs/reselect.cjs",
"module": "./dist/reselect.mjs",
"module": "./dist/reselect.legacy-esm.js",
"types": "./dist/reselect.d.ts",
"exports": {
"./package.json": "./package.json",
Expand Down
29 changes: 27 additions & 2 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ export default defineConfig(options => {
entry: {
reselect: 'src/index.ts'
},
sourcemap: true,
...options
}

return [
// Modern ESM
{
...commonOptions,
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
dts: true,
clean: true,
async onSuccess() {
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
fs.copyFileSync('dist/reselect.mjs', 'dist/reselect.legacy-esm.js')
console.log('onSuccess')

console.log('Generating TS 4.6 types...')
Expand All @@ -42,6 +42,31 @@ export default defineConfig(options => {
console.log('TS 4.6 types done')
}
},

// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
// and optional chaining compiled away
{
...commonOptions,
entry: {
'reselect.legacy-esm': 'src/index.ts'
},
format: ['esm'],
outExtension: () => ({ js: '.js' }),
target: 'es2017'
},
// Browser-ready ESM, production + minified
{
...commonOptions,
entry: {
'reselect.browser': 'src/index.ts'
},
define: {
'process.env.NODE_ENV': JSON.stringify('production')
},
format: ['esm'],
outExtension: () => ({ js: '.mjs' }),
minify: true
},
{
...commonOptions,
format: 'cjs',
Expand Down

0 comments on commit 88c4638

Please sign in to comment.