Skip to content

Commit

Permalink
feat!: Packaging changes.
Browse files Browse the repository at this point in the history
Specifically:

* Remove UMD module support. Per caniuse.com, all browsers that
support WebAssembly also support ES6, save Firefox < 54, which is now
over 5 years old.

* Add `files` to the package config and ensure that all files in
`dist` and `wasm_dist` are included in the package.

Note that Storybook expects CommonJS format, and adding `type: module`
to `package.json` causes it to break. This will be fixed in Storybook
v7, but until then, we implement the workaround described here:

storybookjs/storybook#11587 (comment)
  • Loading branch information
dhess authored and georgefst committed Mar 23, 2023
1 parent 98cff39 commit 2295326
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
File renamed without changes.
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"sideEffects": false,
"version": "0.0.2",
"description": "",
"main": "./dist/tidy.umd.js",
"module": "./dist/tidy.es.mjs",
"type": "module",
"files": ["dist/**/*", "wasm_dist/**/*"],
"main": "./dist/tidy.js",
"module": "./dist/tidy.js",
"types": "./dist/index.d.ts",
"source": "./src/index.ts",
"exports": {
".": {
"import": "./dist/tidy.es.mjs",
"require": "./dist/tidy.umd.js"
"import": "./dist/tidy.js"
}
},
"scripts": {
Expand All @@ -25,13 +26,7 @@
"build-storybook": "build-storybook",
"bench:wasm": "node --expose-gc test/benchmark.mjs"
},
"keywords": [
"tree",
"visualization",
"wasm",
"mindmap",
"rust"
],
"keywords": ["tree", "visualization", "wasm", "mindmap", "rust"],
"license": "MIT",
"author": "Zixuan Chen",
"repository": {
Expand Down
9 changes: 2 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ export default defineConfig({
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'tidy',
fileName: (format) => {
if (format === 'es') {
return 'tidy.es.mjs';
}

return `tidy.${format}.js`;
},
fileName: 'tidy',
formats: ['es'],
},
rollupOptions: {
external: ['react'],
Expand Down

0 comments on commit 2295326

Please sign in to comment.