Skip to content

Commit

Permalink
feat: package type module (#1108)
Browse files Browse the repository at this point in the history
now package is ESM only

BREAKING CHANGE: no commonjs support
  • Loading branch information
dangreen authored Nov 16, 2022
1 parent 7f3ec96 commit 6eb8ce7
Show file tree
Hide file tree
Showing 15 changed files with 3,189 additions and 3,775 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
# builds
package
dist
storybook-static

# misc
.DS_Store
Expand Down
11 changes: 0 additions & 11 deletions .size-limit.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
[
{
"path": "dist/index.cjs",
"limit": "1.75 KB",
"webpack": false,
"running": false
},
{
"path": "dist/index.cjs",
"limit": "900 B",
"import": "{ Chart }"
},
{
"path": "dist/index.js",
"limit": "1.6 KB",
Expand Down
17 changes: 13 additions & 4 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
const path = require('path');
const { mergeConfig } = require('vite');

module.exports = {
core: {
builder: '@storybook/builder-vite',
},
viteFinal(config) {
return mergeConfig(config, {
resolve: {
alias: {
'react-chartjs-2': path.resolve(__dirname, '../src'),
},
},
});
},
stories: ['../stories/*.tsx'],
addons: [
'@storybook/addon-docs',
'@storybook/addon-controls',
'@storybook/addon-actions',
],
webpackFinal(config) {
config.resolve.alias['react-chartjs-2'] = path.resolve(__dirname, '../src');
return config;
},
};
3 changes: 3 additions & 0 deletions .storybook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "react-chartjs-2",
"type": "module",
"version": "4.3.1",
"description": "React components for Chart.js",
"author": "Jeremy Ayerst",
Expand All @@ -22,10 +23,12 @@
],
"sideEffects": false,
"types": "./dist/index.d.ts",
"main": "./src/index.tsx",
"exports": "./src/index.ts",
"publishConfig": {
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"directory": "package"
},
"files": [
Expand All @@ -35,7 +38,7 @@
"prepublishOnly": "pnpm test && pnpm build && del ./package && clean-publish",
"postpublish": "del ./package",
"emitDeclarations": "tsc --emitDeclarationOnly",
"build": "rollup -c & pnpm emitDeclarations",
"build": "rollup -c && pnpm emitDeclarations",
"start:storybook": "start-storybook -p 6006 --ci",
"build:storybook": "del ./storybook-static; NODE_ENV=production build-storybook",
"test:lint": "eslint \"src/**/*.{ts,tsx}\" \"stories/**/*.{ts,tsx}\" \"sandboxes/**/*.{ts,tsx}\" \"test/**/*.{ts,tsx}\"",
Expand All @@ -56,18 +59,20 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@commitlint/cz-commitlint": "^17.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-node-resolve": "^15.0.1",
"@size-limit/preset-big-lib": "^8.0.0",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-controls": "^6.3.12",
"@storybook/addon-docs": "^6.3.12",
"@storybook/addons": "^6.3.12",
"@storybook/builder-vite": "^0.2.5",
"@storybook/client-api": "^6.5.13",
"@storybook/client-logger": "^6.5.13",
"@storybook/react": "^6.3.12",
"@swc/core": "^1.2.95",
"@swc/core": "^1.3.17",
"@swc/helpers": "^0.4.0",
"@testing-library/jest-dom": "^5.5.0",
"@testing-library/react": "^13.0.0",
Expand Down Expand Up @@ -105,18 +110,17 @@
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-test-renderer": "^18.0.0",
"rollup": "^2.58.0",
"rollup-plugin-swc": "^0.2.0",
"rollup": "^3.3.0",
"rollup-plugin-swc3": "^0.7.0",
"simple-git-hooks": "^2.6.1",
"simple-github-release": "^1.0.0",
"size-limit": "^8.0.0",
"standard-version": "^9.3.1",
"tsd": "^0.24.0",
"typescript": "^4.4.3",
"typescript": "^4.9.3",
"vite": "^3.2.4",
"vitest": "^0.25.2",
"vitest-canvas-mock": "^0.2.1",
"webpack": "^5.58.2"
"vitest-canvas-mock": "^0.2.1"
},
"tsd": {
"directory": "./test",
Expand Down
Loading

0 comments on commit 6eb8ce7

Please sign in to comment.