Skip to content

Commit

Permalink
add comments to tsup config
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Nov 8, 2023
1 parent 630b5c4 commit f28e7b7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tsup.config.ts
Expand Up @@ -3,6 +3,7 @@ import { readFile } from "fs/promises";
import { globalPackages as globalManagerPackages } from "@storybook/manager/globals";
import { globalPackages as globalPreviewPackages } from "@storybook/preview/globals";

// The current browsers supported by Storybook v7
const BROWSER_TARGET: Options['target'] = ["chrome100", "safari15", "firefox91"];
const NODE_TARGET: Options['target'] = ["node16"];

Expand All @@ -16,6 +17,15 @@ type BundlerConfig = {
};

export default defineConfig(async (options) => {
// reading the three types of entries from package.json, which has the following structure:
// {
// ...
// "bundler": {
// "exportEntries": ["./src/index.ts"],
// "managerEntries": ["./src/manager.ts"],
// "previewEntries": ["./src/preview.ts"]
// }
// }
const packageJson = await readFile('./package.json', 'utf8').then(JSON.parse) as BundlerConfig;
const {
bundler: {
Expand All @@ -35,6 +45,9 @@ export default defineConfig(async (options) => {

const configs: Options[] = [];

// export entries are entries meant to be manually imported by the user
// they are not meant to be loaded by the manager or preview
// they'll be usable in both node and browser environments, depending on which features and modules they depend on
if (exportEntries.length) {
configs.push({
...commonConfig,
Expand All @@ -49,6 +62,9 @@ export default defineConfig(async (options) => {
});
}

// manager entries are entries meant to be loaded into the manager UI
// they'll have manager-specific packages externalized and they won't be usable in node
// they won't have types generated for them as they're usually loaded automatically by Storybook
if (managerEntries.length) {
configs.push({
...commonConfig,
Expand All @@ -60,6 +76,9 @@ export default defineConfig(async (options) => {
});
}

// preview entries are entries meant to be loaded into the preview iframe
// they'll have preview-specific packages externalized and they won't be usable in node
// they won't have types generated for them as they're usually loaded automatically by Storybook
if (previewEntries.length) {
configs.push({
...commonConfig,
Expand Down

0 comments on commit f28e7b7

Please sign in to comment.