Skip to content

Commit 6eb8ce7

Browse files
authored
feat: package type module (#1108)
now package is ESM only BREAKING CHANGE: no commonjs support
1 parent 7f3ec96 commit 6eb8ce7

15 files changed

+3189
-3775
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules
66
# builds
77
package
88
dist
9+
storybook-static
910

1011
# misc
1112
.DS_Store

.size-limit.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
[
2-
{
3-
"path": "dist/index.cjs",
4-
"limit": "1.75 KB",
5-
"webpack": false,
6-
"running": false
7-
},
8-
{
9-
"path": "dist/index.cjs",
10-
"limit": "900 B",
11-
"import": "{ Chart }"
12-
},
132
{
143
"path": "dist/index.js",
154
"limit": "1.6 KB",

.storybook/main.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
const path = require('path');
2+
const { mergeConfig } = require('vite');
23

34
module.exports = {
5+
core: {
6+
builder: '@storybook/builder-vite',
7+
},
8+
viteFinal(config) {
9+
return mergeConfig(config, {
10+
resolve: {
11+
alias: {
12+
'react-chartjs-2': path.resolve(__dirname, '../src'),
13+
},
14+
},
15+
});
16+
},
417
stories: ['../stories/*.tsx'],
518
addons: [
619
'@storybook/addon-docs',
720
'@storybook/addon-controls',
821
'@storybook/addon-actions',
922
],
10-
webpackFinal(config) {
11-
config.resolve.alias['react-chartjs-2'] = path.resolve(__dirname, '../src');
12-
return config;
13-
},
1423
};

.storybook/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

package.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "react-chartjs-2",
3+
"type": "module",
34
"version": "4.3.1",
45
"description": "React components for Chart.js",
56
"author": "Jeremy Ayerst",
@@ -22,10 +23,12 @@
2223
],
2324
"sideEffects": false,
2425
"types": "./dist/index.d.ts",
25-
"main": "./src/index.tsx",
26+
"exports": "./src/index.ts",
2627
"publishConfig": {
27-
"main": "./dist/index.cjs",
28-
"module": "./dist/index.js",
28+
"exports": {
29+
"import": "./dist/index.js",
30+
"types": "./dist/index.d.ts"
31+
},
2932
"directory": "package"
3033
},
3134
"files": [
@@ -35,7 +38,7 @@
3538
"prepublishOnly": "pnpm test && pnpm build && del ./package && clean-publish",
3639
"postpublish": "del ./package",
3740
"emitDeclarations": "tsc --emitDeclarationOnly",
38-
"build": "rollup -c & pnpm emitDeclarations",
41+
"build": "rollup -c && pnpm emitDeclarations",
3942
"start:storybook": "start-storybook -p 6006 --ci",
4043
"build:storybook": "del ./storybook-static; NODE_ENV=production build-storybook",
4144
"test:lint": "eslint \"src/**/*.{ts,tsx}\" \"stories/**/*.{ts,tsx}\" \"sandboxes/**/*.{ts,tsx}\" \"test/**/*.{ts,tsx}\"",
@@ -56,18 +59,20 @@
5659
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
5760
},
5861
"devDependencies": {
59-
"@babel/core": "^7.15.8",
6062
"@commitlint/cli": "^17.0.0",
6163
"@commitlint/config-conventional": "^17.0.0",
6264
"@commitlint/cz-commitlint": "^17.0.0",
63-
"@rollup/plugin-node-resolve": "^13.0.5",
65+
"@rollup/plugin-node-resolve": "^15.0.1",
6466
"@size-limit/preset-big-lib": "^8.0.0",
6567
"@storybook/addon-actions": "^6.3.12",
6668
"@storybook/addon-controls": "^6.3.12",
6769
"@storybook/addon-docs": "^6.3.12",
6870
"@storybook/addons": "^6.3.12",
71+
"@storybook/builder-vite": "^0.2.5",
72+
"@storybook/client-api": "^6.5.13",
73+
"@storybook/client-logger": "^6.5.13",
6974
"@storybook/react": "^6.3.12",
70-
"@swc/core": "^1.2.95",
75+
"@swc/core": "^1.3.17",
7176
"@swc/helpers": "^0.4.0",
7277
"@testing-library/jest-dom": "^5.5.0",
7378
"@testing-library/react": "^13.0.0",
@@ -105,18 +110,17 @@
105110
"react": "^18.0.0",
106111
"react-dom": "^18.0.0",
107112
"react-test-renderer": "^18.0.0",
108-
"rollup": "^2.58.0",
109-
"rollup-plugin-swc": "^0.2.0",
113+
"rollup": "^3.3.0",
114+
"rollup-plugin-swc3": "^0.7.0",
110115
"simple-git-hooks": "^2.6.1",
111116
"simple-github-release": "^1.0.0",
112117
"size-limit": "^8.0.0",
113118
"standard-version": "^9.3.1",
114119
"tsd": "^0.24.0",
115-
"typescript": "^4.4.3",
120+
"typescript": "^4.9.3",
116121
"vite": "^3.2.4",
117122
"vitest": "^0.25.2",
118-
"vitest-canvas-mock": "^0.2.1",
119-
"webpack": "^5.58.2"
123+
"vitest-canvas-mock": "^0.2.1"
120124
},
121125
"tsd": {
122126
"directory": "./test",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy