diff --git a/package.json b/package.json index 8547230..10d06d5 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,16 @@ "version": "5.1.0", "description": "Moneytree Link JavaScript SDK", "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist/" ], diff --git a/sample/vite.config.ts b/sample/vite.config.ts index 884a8a0..c5d7456 100644 --- a/sample/vite.config.ts +++ b/sample/vite.config.ts @@ -7,10 +7,5 @@ export default defineConfig({ server: { // So it can run without conflicting with Vault port: 9001 - }, - - // So it can bundle CJS -> ESM through the portal - optimizeDeps: { - include: ['@moneytree/mt-link-javascript-sdk'] } }); diff --git a/vite.config.ts b/vite.config.ts index 47134a3..27c801d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,16 +15,22 @@ export default defineConfig({ build: { outDir: 'dist', lib: { - entry: path.resolve(__dirname, 'src/index.ts'), - formats: ['cjs'], - fileName: () => 'index.js' + entry: path.resolve(__dirname, 'src/index.ts') }, rollupOptions: { - output: { - // Match the old webpack commonjs2 output shape: module.exports carries - // both the default export (under `.default`) and all named exports. - exports: 'named' - } + output: [ + { + format: 'cjs', + entryFileNames: 'index.js', + // Match the old webpack commonjs2 output shape: module.exports carries + // both the default export (under `.default`) and all named exports. + exports: 'named' + }, + { + format: 'es', + entryFileNames: 'index.mjs' + } + ] } } });