Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename to @storybook/builder-vite #293

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/buildAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch]

defaults:
run:
working-directory: packages/storybook-builder-vite
working-directory: packages/builder-vite

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
2. Clone forked repository:

```
git clone https://github.com/YOUR_USERNAME/storybook-builder-vite
cd storybook-builder-vite
git clone https://github.com/YOUR_USERNAME/builder-vite
cd builder-vite
```

3. Install dependencies:
Expand Down
2 changes: 1 addition & 1 deletion examples/react-ts/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-a11y', '@storybook/addon-links', '@storybook/addon-essentials'],
core: {
builder: 'storybook-builder-vite',
builder: '@storybook/builder-vite',
},
features: {
storyStoreV7: true,
Expand Down
2 changes: 1 addition & 1 deletion examples/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"@storybook/addon-a11y": "^6.5.0-alpha.49",
"@storybook/addon-docs": "^6.5.0-alpha.49",
"@storybook/addon-essentials": "^6.5.0-alpha.49",
"@storybook/builder-vite": "workspace:*",
"@storybook/react": "^6.5.0-alpha.49",
"@storybook/test-runner": "^0.0.4",
"http-server": "^14.1.0",
"jest": "^27.5.1",
"npm-run-all": "^4.1.5",
"storybook-builder-vite": "workspace:*",
"typescript": "^4.5.4",
"vite": "2.9.0-beta.8",
"wait-on": "^6.0.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/react/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-a11y', '@storybook/addon-links', '@storybook/addon-essentials'],
core: {
builder: 'storybook-builder-vite',
builder: '@storybook/builder-vite',
},
features: {
storyStoreV7: false,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"@storybook/addon-a11y": "^6.5.0-alpha.49",
"@storybook/addon-docs": "^6.5.0-alpha.49",
"@storybook/addon-essentials": "^6.5.0-alpha.49",
"@storybook/builder-vite": "workspace:*",
"@storybook/react": "^6.5.0-alpha.49",
"@storybook/test-runner": "^0.0.4",
"http-server": "^14.1.0",
"jest": "^27.5.1",
"npm-run-all": "^4.1.5",
"storybook-builder-vite": "workspace:*",
"vite": "2.9.0-beta.8",
"wait-on": "^6.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx|svelte)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-svelte-csf'],
core: {
builder: 'storybook-builder-vite',
builder: '@storybook/builder-vite',
},
async viteFinal(config, { configType }) {
// customize the Vite config here
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"@storybook/addon-essentials": "^6.5.0-alpha.49",
"@storybook/addon-links": "^6.5.0-alpha.49",
"@storybook/addon-svelte-csf": "^1.1.0",
"@storybook/builder-vite": "workspace:*",
"@storybook/svelte": "^6.5.0-alpha.49",
"@storybook/test-runner": "^0.0.4",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.37",
"@tsconfig/svelte": "^3.0.0",
"http-server": "^14.1.0",
"jest": "^27.5.1",
"npm-run-all": "^4.1.5",
"storybook-builder-vite": "workspace:*",
"svelte-preprocess": "^4.10.4",
"typescript": "^4.5.5",
"vite": "2.9.0-beta.8",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
core: {
builder: 'storybook-builder-vite',
builder: '@storybook/builder-vite',
},
async viteFinal(config, { configType }) {
// customize the Vite config here
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"devDependencies": {
"@storybook/addon-a11y": "^6.5.0-alpha.49",
"@storybook/addon-essentials": "^6.5.0-alpha.49",
"@storybook/builder-vite": "workspace:*",
"@storybook/test-runner": "^0.0.4",
"@storybook/vue3": "^6.5.0-alpha.49",
"@vitejs/plugin-vue": "^1.10.2",
"http-server": "^14.1.0",
"jest": "^27.5.1",
"npm-run-all": "^4.1.5",
"storybook-builder-vite": "workspace:*",
"vite": "2.9.0-beta.8",
"wait-on": "^6.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/workspaces/packages/catalog/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
stories: ['../../app/stories/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-a11y', '@storybook/addon-links', '@storybook/addon-essentials'],
core: {
builder: 'storybook-builder-vite',
builder: '@storybook/builder-vite',
},
features: {
storyStoreV7: true,
Expand Down
2 changes: 1 addition & 1 deletion examples/workspaces/packages/catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@storybook/addon-a11y": "^6.5.0-alpha.49",
"@storybook/addon-docs": "^6.5.0-alpha.49",
"@storybook/addon-essentials": "^6.5.0-alpha.49",
"@storybook/builder-vite": "workspace:*",
"@storybook/react": "^6.5.0-alpha.49",
"storybook-builder-vite": "workspace:*",
"vite": "2.9.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"scripts": {
"build-examples": "yarn workspaces foreach --include 'example-*' -p run build-storybook",
"test-ci": "yarn workspaces foreach --exclude 'example-svelte' -p run test-ci",
"start": "cd packages/storybook-builder-vite && tsc -w",
"prepublish": "cd packages/storybook-builder-vite && tsc",
"start": "cd packages/builder-vite && tsc -w",
"prepublish": "cd packages/builder-vite && tsc",
"lint": "yarn lint:prettier && yarn lint:eslint",
"lint:prettier": "prettier --write .",
"lint:eslint": "eslint \"**/*.{ts,tsx,js,jsx,mjs,cjs}\" --fix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ feel free to create an issue or send a pull request!
The Vite builder cannot build itself.
Are you willing to contribute?

https://github.com/eirslett/storybook-builder-vite/issues/11
https://github.com/storybookjs/builder-vite/issues/11

Please read the [How to contribute](/CONTRIBUTING.md) guide.

### Installation

```bash
npm install storybook-builder-vite --save-dev
npm install @storybook/builder-vite --save-dev
```

or

```bash
yarn add --dev storybook-builder-vite
yarn add --dev @storybook/builder-vite
```

### Usage

In your `main.js` configuration file,
set `core: { builder: "storybook-builder-vite" }`.
set `core: { builder: "@storybook/builder-vite" }`.

> For autoreload of stories to work, they need to have `.stories.tsx` file suffix.
> See also [#53](https://github.com/eirslett/storybook-builder-vite/pull/53)
> See also [#53](https://github.com/storybookjs/builder-vite/pull/53)

The builder supports both development mode in Storybook, and building a static production version.

Expand Down Expand Up @@ -97,22 +97,22 @@ storybook configuration directory. This can be overridden in viteFinal.
```
npm init @vitejs/app vite-react-app --template react && cd vite-react-app
npm install # or yarn
npx sb@next init --builder storybook-builder-vite && npm run storybook
npx sb@next init --builder @storybook/builder-vite && npm run storybook
```

## Known issues

- HMR: saving a story file does not hot-module-reload. In svelte, the page is not reloaded either (https://github.com/eirslett/storybook-builder-vite/issues/209). HMR should work when saving component files.
- HMR: saving a story file does not hot-module-reload. In svelte, the page is not reloaded either (https://github.com/storybookjs/builder-vite/issues/209). HMR should work when saving component files.
- Prebundling: Vite restarts if it detects new dependencies which it did not know about and needs to pre-bundle. This breaks within storybook, with confusing error messages. If you see a message in your terminal like `[vite] new dependencies found:`, please add those dependencies to your `optimizeDeps.include` in `viteFinal`. E.g. `config.optimizeDeps.include = [...(config.optimizeDeps?.include ?? []), "storybook-dark-mode"],`.
- MDX pages are broken when emotion 11 is installed: Adding the configuration [here](https://github.com/eirslett/storybook-builder-vite/issues/219#issuecomment-1023666193) should fix this.
- MDX pages are broken when emotion 11 is installed: Adding the configuration [here](https://github.com/storybookjs/builder-vite/issues/219#issuecomment-1023666193) should fix this.

## Contributing

Contributions are welcome!

### About this codebase

The code is a monorepo with the core `storybook-builder-vite` package,
The code is a monorepo with the core `@storybook/builder-vite` package,
and examples (like `packages/example-react`) to test the builder implementation with.

Similar to the main storybook monorepo, you need yarn , because the project is organized as yarn workspaces.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): Requ
return;
}

// We need to handle `html-proxy` params for style tag HMR https://github.com/eirslett/storybook-builder-vite/issues/266#issuecomment-1055677865
// We need to handle `html-proxy` params for style tag HMR https://github.com/storybookjs/builder-vite/issues/266#issuecomment-1055677865
// e.g. /iframe.html?html-proxy&index=0.css
if (req.query['html-proxy'] !== undefined) {
next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { promise as glob } from 'glob-promise';

import type { Options, StoriesEntry } from '@storybook/core-common';

// TODO: Merge with https://github.com/eirslett/storybook-builder-vite/pull/182
// TODO: Merge with https://github.com/storybookjs/builder-vite/pull/182
export async function listStories({ presets, configDir }: Options) {
return (
await Promise.all(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "storybook-builder-vite",
"name": "@storybook/builder-vite",
"version": "0.1.22",
"description": "An experimental plugin to run and build Storybooks with Vite",
"main": "dist/index.js",
Expand All @@ -8,10 +8,10 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/eirslett/storybook-builder-vite.git",
"directory": "package/storybook-builder-vite"
"url": "https://github.com/storybookjs/builder-vite.git",
"directory": "packages/builder-vite"
},
"homepage": "https://github.com/eirslett/storybook-builder-vite/#readme",
"homepage": "https://github.com/storybookjs/builder-vite/#readme",
"dependencies": {
"@joshwooding/vite-plugin-react-docgen-typescript": "0.0.2",
"@mdx-js/mdx": "^1.6.22",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function pluginConfig(options: ExtendedOptions, _type: PluginConfig
} catch (err) {
if ((err as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {
throw new Error(
'storybook-builder-vite requires @vitejs/plugin-vue to be installed ' +
'@storybook/builder-vite requires @vitejs/plugin-vue to be installed ' +
'when using @storybook/vue or @storybook/vue3.' +
' Please install it and start storybook again.'
);
Expand All @@ -73,7 +73,8 @@ export async function pluginConfig(options: ExtendedOptions, _type: PluginConfig
} catch (err) {
if ((err as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {
throw new Error(
'storybook-builder-vite requires @sveltejs/vite-plugin-svelte to be installed when using @storybook/svelte.' +
'@storybook/builder-vite requires @sveltejs/vite-plugin-svelte to be installed' +
' when using @storybook/svelte.' +
' Please install it and start storybook again.'
);
}
Expand All @@ -86,7 +87,7 @@ export async function pluginConfig(options: ExtendedOptions, _type: PluginConfig
} catch (err) {
if ((err as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {
throw new Error(
'storybook-builder-vite requires @storybook/addon-svelte-csf to be installed when using @storybook/svelte.' +
'@storybook/builder-vite requires @storybook/addon-svelte-csf to be installed when using @storybook/svelte.' +
' Please install it and start storybook again.'
);
}
Expand Down
Loading