From 7828a64ff6f5ab507ccf9dc60aa9f568db40922a Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Fri, 22 Mar 2024 10:50:22 -0500 Subject: [PATCH] Fix webpack 4 support by setting `target: es2017` for `redux.legacy-esm.js` (#4687) --- tsup.config.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tsup.config.ts b/tsup.config.ts index bfffd883f0..9f9235d355 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -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 = { @@ -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 {