Skip to content

Commit

Permalink
improve react-ui-lite bundle config, add sideEffects false
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-burel committed Sep 29, 2022
1 parent daf8208 commit f81be9a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 41 deletions.
1 change: 1 addition & 0 deletions packages/react-ui-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"files": [
"dist/"
],
"sideEffects": false,
"type": "module",
"exports": {
".": "./dist/index.js"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
export { liteFormComponents } from "./formComponents";
export { liteDatatableComponents } from "./datatableComponents";
export { liteCellComponents } from "./cellComponents";
export { liteCoreComponents } from "./coreComponents";

import { liteFormComponents } from "./formComponents";
import { liteDatatableComponents } from "./datatableComponents";
import { liteCellComponents } from "./cellComponents";
import { liteCoreComponents } from "./coreComponents";

/**
* @deprecated 0.6.1
* Use each type of components instead of loading all of them at once
* This will avoid loading form and datatable components, that are very heavy, on every page
* even when they are anot actually used
*/
export const liteVulcanComponents = {
...liteDatatableComponents,
...liteCellComponents,
...liteCoreComponents,
...liteFormComponents,
};
export { liteFormComponents } from "./formComponents.js";
export { liteDatatableComponents } from "./datatableComponents.js";
export { liteCellComponents } from "./cellComponents.js";
export { liteCoreComponents } from "./coreComponents.js";
1 change: 1 addition & 0 deletions packages/react-ui-lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"files": [
"dist/"
],
"sideEffects": false,
"type": "module",
"exports": {
".": "./dist/index.js"
Expand Down
41 changes: 22 additions & 19 deletions packages/react-ui-lite/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "tsup";
import { defineConfig, Format } from "tsup";
import path from "path";

const commonConfig = {
Expand All @@ -8,38 +8,41 @@ const commonConfig = {
// dts: true,
sourcemap: true,
tsconfig: path.resolve(__dirname, "./tsconfig.build.json"),
outDir: "dist",
format: ["esm" as Format],
};
export default defineConfig([
// actual exposed modules = 1 per component
{
// This is a demo with one component but you can use a glob here
entry: ["./components/core/*.tsx"],
//["./components/core/Loading.tsx"],
entry: [
"./components/core/!(index).ts?(x)",
"./components/VulcanComponents/liteVulcanComponents/!(index).ts?(x)",
],
...commonConfig,
format: ["esm"],
// TODO: it's not respect automatically
outDir: "dist/components/core",
},
{
// This is a demo with one component but you can use a glob here
entry: ["./components/VulcanComponents/liteVulcanComponents/index.ts"],
//["./components/core/Loading.tsx"],
...commonConfig,
format: ["esm"],
// TODO: it's not respect automatically
outDir: "dist/components/VulcanComponents/liteVulcanComponents",
// For debugging, will output ESbuild metafile
// metafile: true,
esbuildOptions(options, context) {
// the directory structure will be the same as the source
options.outbase = "./";
},
},
// index files to allow named imports
// inspired by react-bootstrap structure
{
entry: ["index.ts", "./components/core/index.ts"],
entry: [
"index.ts",
"./components/core/index.ts",
"./components/VulcanComponents/liteVulcanComponents/index.ts",
],
...commonConfig,
esbuildOptions(options, context) {
// the directory structure will be the same as the source
options.outbase = "./";
},
// index files must NOT be bundled!
// it acts as a map towards bundled components
// but never rebundles them
bundle: false,
format: ["esm"],
outDir: "dist",
},
/*
There is no server/client specific code in this package yet,
Expand Down
1 change: 1 addition & 0 deletions packages/react-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"files": [
"dist/"
],
"sideEffects": false,
"type": "module",
"exports": {
".": "./dist/index.js",
Expand Down

2 comments on commit f81be9a

@vercel
Copy link

@vercel vercel bot commented on f81be9a Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vulcan-npm – ./

vulcan-npm.vercel.app
vulcan-npm-git-main-vulcan.vercel.app
vulcan-npm-vulcan.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f81be9a Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vulcan-docs – ./docusaurus

vulcan-docs-git-main-vulcan.vercel.app
vulcan-docs.vercel.app
vulcan-docs-vulcan.vercel.app

Please sign in to comment.