Skip to content

Commit

Permalink
feat: ensure proper CJS and ESM bundles and add IIFE bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Apr 27, 2024
1 parent a26b37b commit 3d009bc
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
import { defineConfig as defineTsupConfig } from 'tsup';
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { defineConfig, type Options } from 'tsup';

export default defineTsupConfig({
clean: true,
dts: true,
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
minify: false,
skipNodeModulesBundle: true,
sourcemap: true,
target: 'es2020',
tsconfig: 'src/tsconfig.json',
keepNames: true
});
const baseOptions: Options = {
clean: true,
dts: true,
entry: ['src/index.ts'],
minify: false,
sourcemap: true,
target: 'es2020',
tsconfig: 'src/tsconfig.json',
keepNames: true,
treeshake: true,
esbuildPlugins: [nodeModulesPolyfillPlugin()]
};

export default [
defineConfig({
...baseOptions,
outDir: 'dist/cjs',
format: 'cjs',
outExtension: () => ({ js: '.cjs' })
}),
defineConfig({
...baseOptions,
outDir: 'dist/esm',
format: 'esm',
outExtension: () => ({ js: '.mjs' })
}),
defineConfig({
...baseOptions,
globalName: 'NintendoSwitchEshop',
dts: false,
outDir: 'dist/iife',
format: 'iife'
})
];

0 comments on commit 3d009bc

Please sign in to comment.