Skip to content

Commit 3318bf2

Browse files
committed
Build browser ESM and Webpack 4 compat artifacts, and add sourcemaps
1 parent 1a85288 commit 3318bf2

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "5.0.0-alpha.1",
44
"description": "Selectors for Redux.",
55
"main": "./dist/cjs/reselect.cjs",
6-
"module": "./dist/reselect.mjs",
6+
"module": "./dist/reselect.legacy-esm.js",
77
"types": "./dist/reselect.d.ts",
88
"exports": {
99
"./package.json": "./package.json",

tsup.config.ts

+27-2
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ export default defineConfig(options => {
1818
entry: {
1919
reselect: 'src/index.ts'
2020
},
21+
sourcemap: true,
2122
...options
2223
}
2324

2425
return [
26+
// Modern ESM
2527
{
2628
...commonOptions,
2729
format: ['esm'],
2830
outExtension: () => ({ js: '.mjs' }),
2931
dts: true,
3032
clean: true,
3133
async onSuccess() {
32-
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
33-
fs.copyFileSync('dist/reselect.mjs', 'dist/reselect.legacy-esm.js')
3434
console.log('onSuccess')
3535

3636
console.log('Generating TS 4.6 types...')
@@ -42,6 +42,31 @@ export default defineConfig(options => {
4242
console.log('TS 4.6 types done')
4343
}
4444
},
45+
46+
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
47+
// and optional chaining compiled away
48+
{
49+
...commonOptions,
50+
entry: {
51+
'reselect.legacy-esm': 'src/index.ts'
52+
},
53+
format: ['esm'],
54+
outExtension: () => ({ js: '.js' }),
55+
target: 'es2017'
56+
},
57+
// Browser-ready ESM, production + minified
58+
{
59+
...commonOptions,
60+
entry: {
61+
'reselect.browser': 'src/index.ts'
62+
},
63+
define: {
64+
'process.env.NODE_ENV': JSON.stringify('production')
65+
},
66+
format: ['esm'],
67+
outExtension: () => ({ js: '.mjs' }),
68+
minify: true
69+
},
4570
{
4671
...commonOptions,
4772
format: 'cjs',

0 commit comments

Comments
 (0)