Skip to content

Commit

Permalink
Fix webpack 4 support by setting target: es2017 for `redux.legacy-e…
Browse files Browse the repository at this point in the history
…sm.js` (#4687)
  • Loading branch information
aryaemami59 committed Mar 22, 2024
1 parent 81d597f commit 7828a64
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tsup.config.ts
Expand Up @@ -4,7 +4,6 @@ import { defineConfig } from 'tsup'
import * as babel from '@babel/core'
import type { Plugin } from 'esbuild'
import { getBuildExtensions } from 'esbuild-extra'
import fs from 'fs'

// Extract error strings, replace them with error codes, and write messages to a file
const mangleErrorsTransform: Plugin = {
Expand Down Expand Up @@ -44,11 +43,16 @@ export default defineConfig(options => {
format: ['esm'],
outExtension: () => ({ js: '.mjs' }), // Add dts: '.d.ts' when egoist/tsup#1053 lands
dts: true,
clean: true,
async onSuccess() {
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
fs.copyFileSync('dist/redux.mjs', 'dist/redux.legacy-esm.js')
}
clean: true
},
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
{
...commonOptions,
format: ['esm'],
target: 'es2017',
dts: false,
outExtension: () => ({ js: '.js' }),
entry: { 'redux.legacy-esm': 'src/index.ts' }
},
// Browser-ready ESM, production + minified
{
Expand Down

0 comments on commit 7828a64

Please sign in to comment.