From c403cf75caa2cf3766f8d27548fc0e5bf81ff7bb Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Fri, 22 Mar 2024 10:50:35 -0500 Subject: [PATCH] Fix webpack 4 support by setting `target: es2017` for `redux.legacy-esm.js` (#370) --- tsup.config.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tsup.config.ts b/tsup.config.ts index 22b3528..bf1678d 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,5 +1,5 @@ -import { defineConfig, Options } from 'tsup' -import fs from 'fs' +import type { Options } from 'tsup' +import { defineConfig } from 'tsup' export default defineConfig(options => { const commonOptions: Partial = { @@ -15,14 +15,16 @@ export default defineConfig(options => { format: ['esm'], outExtension: () => ({ js: '.mjs' }), dts: true, - clean: true, - onSuccess() { - // Support Webpack 4 by pointing `"module"` to a file with a `.js` extension - fs.copyFileSync( - 'dist/redux-thunk.mjs', - 'dist/redux-thunk.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-thunk.legacy-esm': 'src/index.ts' } }, { ...commonOptions,