Skip to content

Commit 04eba11

Browse files
CopilotTechQuery
andauthored
[optimize] support ESM exports of NPM (#36)
Co-authored-by: TechQuery <shiy2008@gmail.com>
1 parent c8af6d3 commit 04eba11

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web-utility",
3-
"version": "4.7.1",
3+
"version": "4.7.2",
44
"license": "LGPL-3.0",
55
"author": "shiy2008@gmail.com",
66
"description": "Web front-end toolkit based on TypeScript",
@@ -22,7 +22,16 @@
2222
"source": "source/index.ts",
2323
"types": "dist/index.d.ts",
2424
"main": "dist/index.js",
25-
"module": "dist/index.esm.js",
25+
"module": "dist/index.mjs",
26+
"exports": {
27+
".": {
28+
"types": "./dist/index.d.ts",
29+
"import": "./dist/index.mjs",
30+
"require": "./dist/index.js",
31+
"default": "./dist/index.js"
32+
},
33+
"./package.json": "./package.json"
34+
},
2635
"dependencies": {
2736
"@swc/helpers": "^0.5.23",
2837
"regenerator-runtime": "^0.14.1"

‎test/package.spec.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import packageJSON from '../package.json';
2+
3+
describe('Package exports', () => {
4+
it('should expose standard npm ESM & CJS entry points', () => {
5+
expect(packageJSON.types).toBe('dist/index.d.ts');
6+
expect(packageJSON.source).toBe('source/index.ts');
7+
expect(packageJSON.main).toBe('dist/index.js');
8+
expect(packageJSON.module).toBe('dist/index.mjs');
9+
10+
expect(packageJSON.exports).toEqual({
11+
'.': {
12+
types: './dist/index.d.ts',
13+
import: './dist/index.mjs',
14+
require: './dist/index.js',
15+
default: './dist/index.js'
16+
},
17+
'./package.json': './package.json'
18+
});
19+
});
20+
});

0 commit comments

Comments
 (0)