Skip to content

Commit c0d0294

Browse files
committed
Output a separate "legacy ESM" artifact for Webpack 4
1 parent 0209f09 commit c0d0294

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
run: yarn test
146146
if: matrix.example != 'are-the-types-wrong'
147147

148-
- name: Run test step
148+
- name: Run test step (attw)
149149
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
150150
# Ignore "FalseCJS" errors in the `attw` job
151151
run: yarn test -n FalseCJS

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"author": "Dan Abramov <dan.abramov@me.com>",
1717
"main": "dist/cjs/redux-thunk.cjs",
18-
"module": "dist/redux-thunk.mjs",
18+
"module": "dist/redux-thunk.legacy-esm.js",
1919
"types": "dist/redux-thunk.d.ts",
2020
"exports": {
2121
"./package.json": "./package.json",

tsup.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig, Options } from 'tsup'
2+
import fs from 'fs'
23

34
export default defineConfig(options => {
45
const commonOptions: Partial<Options> = {
@@ -14,7 +15,14 @@ export default defineConfig(options => {
1415
format: ['esm'],
1516
outExtension: () => ({ js: '.mjs' }),
1617
dts: true,
17-
clean: true
18+
clean: true,
19+
onSuccess() {
20+
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
21+
fs.copyFileSync(
22+
'dist/redux-thunk.mjs',
23+
'dist/redux-thunk.legacy-esm.js'
24+
)
25+
}
1826
},
1927
{
2028
...commonOptions,

0 commit comments

Comments
 (0)