Skip to content

Commit 0268f47

Browse files
authored
Merge pull request #25 from DanielleHuisman/main
Add ESM export
2 parents c178950 + 951c1bb commit 0268f47

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
"vite-plugin",
1818
"vite-plugin-graphql-codegen"
1919
],
20-
"type": "commonjs",
21-
"main": "dist/index.js",
22-
"types": "dist/index.d.ts",
20+
"type": "module",
21+
"exports": "./dist/index.js",
22+
"main": "./dist/index.cjs",
23+
"types": "./dist/index.d.ts",
2324
"files": [
2425
"dist"
2526
],

tsup.config.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ export default defineConfig({
66
sourcemap: true,
77
clean: true,
88
skipNodeModulesBundle: true,
9-
format: ['cjs'],
9+
format: ['cjs', 'esm'],
1010
esbuildOptions: (options) => {
11-
options.footer = {
12-
// This will ensure we can continue writing this plugin
13-
// as a modern ECMA module, while still publishing this as a CommonJS
14-
// library with a default export, as that's how ESLint expects plugins to look.
15-
// @see https://github.com/evanw/esbuild/issues/1182#issuecomment-1011414271
16-
js: 'module.exports = module.exports.default;',
17-
};
11+
if (options.format === 'cjs') {
12+
options.footer = {
13+
// This will ensure we can continue writing this plugin
14+
// as a modern ECMA module, while still publishing this as a CommonJS
15+
// library with a default export, as that's how ESLint expects plugins to look.
16+
// @see https://github.com/evanw/esbuild/issues/1182#issuecomment-1011414271
17+
js: 'module.exports = module.exports.default;',
18+
};
19+
}
1820
},
1921
});

0 commit comments

Comments
 (0)