From 485f38c77858d5b3cf263d19558a28c546fa261a Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 28 Sep 2022 11:53:45 +0200 Subject: [PATCH] convert lib/core-server to be build using tsup --- code/lib/core-server/package.json | 30 ++++++++++++++++--- .../core-server/src/utils/server-statics.ts | 6 +++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index 2dcc4346029b..225ae4c4812d 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -19,9 +19,22 @@ "url": "https://opencollective.com/storybook" }, "license": "MIT", - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/types/index.d.ts", + "exports": { + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./standalone": { + "require": "./dist/standalone.js", + "import": "./dist/standalone.mjs", + "types": "./dist/standalone.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", "files": [ "dist/**/*", "public/**/*", @@ -30,7 +43,7 @@ ], "scripts": { "check": "../../../scripts/node_modules/.bin/tsc --noEmit", - "prep": "node ../../../scripts/prepare.js" + "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { "@aw-web-design/x-default-browser": "1.4.88", @@ -101,5 +114,14 @@ "publishConfig": { "access": "public" }, + "bundler": { + "platform": "node", + "entries": [ + "./src/index.ts", + "./src/standalone.ts", + "./src/presets/babel-cache-preset.ts", + "./src/presets/common-preset.ts" + ] + }, "gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f" } diff --git a/code/lib/core-server/src/utils/server-statics.ts b/code/lib/core-server/src/utils/server-statics.ts index 585529cd142e..316fef1d8557 100644 --- a/code/lib/core-server/src/utils/server-statics.ts +++ b/code/lib/core-server/src/utils/server-statics.ts @@ -9,7 +9,11 @@ import favicon from 'serve-favicon'; import { dedent } from 'ts-dedent'; -const defaultFavIcon = require.resolve('@storybook/core-server/public/favicon.ico'); +const defaultFavIcon = path.join( + path.dirname(require.resolve('@storybook/core-server/package.json')), + 'public', + 'favicon.ico' +); export async function useStatics(router: any, options: Options) { let hasCustomFavicon = false;