Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ff7b7e1
Svelte: Always inject doc metadata
j3rem1e Sep 6, 2023
4f6667d
Svelte: Fix parsing of ecma v12 by sveltedoc-parser
j3rem1e Sep 6, 2023
e0fb289
Adding e2e to test Svelte documentation
j3rem1e Sep 9, 2023
4f53511
Svelte: Fix documentation for typescript component with vite
j3rem1e Sep 12, 2023
a1860c0
Fix e2e tests
j3rem1e Sep 13, 2023
048d7c6
Move e2e tests into ButtonView
j3rem1e Sep 14, 2023
d3b51fa
Remove the possibility to configure doc preprocessors
j3rem1e Sep 17, 2023
70d43ab
Ignore type checking of globalThis
j3rem1e Sep 18, 2023
1a75c1c
Add Vite 5 to peer dependencies
IanVS Oct 5, 2023
12448d8
Install vite beta in sandboxes
IanVS Oct 5, 2023
77cd89c
Update @joshwooding/vite-plugin-react-docgen-typescript
IanVS Oct 5, 2023
cc10c62
Update yarn lock
IanVS Oct 5, 2023
f262b63
Use dynamic import of Vite functions
IanVS Oct 5, 2023
954c76c
Use Vite 5 beta in devDependencies
IanVS Oct 5, 2023
619f838
Use dynamic import of slash
IanVS Oct 5, 2023
a7bff76
Try to use ESM mocks for jest test
IanVS Oct 5, 2023
73a8e8f
Revert "Try to use ESM mocks for jest test"
IanVS Oct 5, 2023
df43854
Revert "Use Vite 5 beta in devDependencies"
IanVS Oct 5, 2023
cf03660
Revert "Use dynamic import of slash"
IanVS Oct 5, 2023
d138cf6
Add missing await
IanVS Oct 5, 2023
4fa2fa5
Merge branch 'next' into vite-5
IanVS Oct 5, 2023
779c899
Update code/frameworks/react-vite/package.json
IanVS Oct 6, 2023
2aacb58
Update yarn.lock
IanVS Oct 6, 2023
95e642f
comment updates
JReinhold Oct 9, 2023
0c704d8
Merge branch 'next' into bug/24008
JReinhold Oct 9, 2023
270c94d
support javascript in Svelte Vite docgen
JReinhold Oct 9, 2023
7a34d99
Stick with @joshwooding/vite-plugin-react-docgen-typescript: "0.3.0"
IanVS Oct 9, 2023
4e3fc89
Merge branch 'next' into vite-5
IanVS Oct 9, 2023
77336f2
Merge branch 'next' into vite-5
IanVS Oct 11, 2023
08d3aac
fix: allow loading standalone directives
osnoser1 Oct 12, 2023
3ea404c
Fix sandbox creation scripts for main and next
valentinpalkovic Oct 12, 2023
e9f2e1f
Merge pull request #24454 from storybookjs/valentin/fix-sandbox-creation
valentinpalkovic Oct 12, 2023
11aeb97
Readd Angular 17 prerelease sandbox
valentinpalkovic Oct 12, 2023
4c43bc5
Add Next.js Canary sandbox
valentinpalkovic Oct 12, 2023
2a8ab8e
Fix CircleCI parallelism
valentinpalkovic Oct 12, 2023
99382b9
Temporarily change ref branch in generate-sandboxes-next.yml
valentinpalkovic Oct 12, 2023
20e69a6
Add inDevelopment for Next.js Prerelease sandbox
valentinpalkovic Oct 12, 2023
8c0453e
Fix creating Nextjs Sandbox
valentinpalkovic Oct 12, 2023
296202b
Temporarily only create angular/prerelease and nextjs/prerelease sand…
valentinpalkovic Oct 12, 2023
c083802
Merge branch 'next' into vite-5
IanVS Oct 12, 2023
10f11ed
Generate all sandboxes again
valentinpalkovic Oct 12, 2023
5f22901
fix: syntax error in property extractor test
osnoser1 Oct 12, 2023
13b5fc7
Merge branch 'next' into bugfix/standalone-angular-directives
osnoser1 Oct 12, 2023
6da3c0d
Fix Next.js canary
valentinpalkovic Oct 12, 2023
3c0f77a
Fix parallelism config for CircleCI
valentinpalkovic Oct 12, 2023
62e4b47
Revert ref in genreate-sandboxes-next.yml
valentinpalkovic Oct 12, 2023
66b15ff
Update code/frameworks/nextjs/src/dependency-map.ts
valentinpalkovic Oct 12, 2023
c8ec3a6
Fix Next.js 12
valentinpalkovic Oct 12, 2023
eb52b37
Fix Next.js default sandboxes
valentinpalkovic Oct 12, 2023
74bd3b0
Fix Next.js 12
valentinpalkovic Oct 12, 2023
6b2150c
Merge pull request #24453 from storybookjs/valentin/setup-sandboxes
valentinpalkovic Oct 12, 2023
8b0ffb0
Merge branch 'next' into vite-5
IanVS Oct 13, 2023
a427c33
Merge pull request #24395 from storybookjs/vite-5
JReinhold Oct 13, 2023
84d046d
Merge branch 'next' into bugfix/standalone-angular-directives
valentinpalkovic Oct 13, 2023
3a77b6c
Merge branch 'next' into bug/24008
JReinhold Oct 13, 2023
048272f
Merge pull request #24448 from osnoser1/bugfix/standalone-angular-dir…
valentinpalkovic Oct 13, 2023
995e064
Merge pull request #24096 from j3rem1e/bug/24008
yannbf Oct 13, 2023
c0f87fb
Write changelog for 7.5.0-alpha.7 [skip ci]
storybook-bot Oct 13, 2023
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
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,30 +609,30 @@ workflows:
requires:
- build
- create-sandboxes:
parallelism: 34
parallelism: 36
requires:
- build
# - smoke-test-sandboxes: # disabled for now
# requires:
# - create-sandboxes
- build-sandboxes:
parallelism: 34
parallelism: 36
requires:
- create-sandboxes
- chromatic-sandboxes:
parallelism: 31
parallelism: 33
requires:
- build-sandboxes
- e2e-production:
parallelism: 31
parallelism: 33
requires:
- build-sandboxes
- e2e-dev:
parallelism: 4
requires:
- create-sandboxes
- test-runner-production:
parallelism: 31
parallelism: 33
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/generate-sandboxes-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
CLEANUP_SANDBOX_NODE_MODULES: true
steps:
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Setup git user
run: |
git config --global user.name "Storybook Bot"
Expand All @@ -43,7 +43,7 @@ jobs:
run: yarn wait-on http://localhost:6001
working-directory: ./code
- name: Generate
run: yarn generate-sandboxes --local-registry --exclude=angular-cli/prerelease
run: yarn generate-sandboxes --local-registry
working-directory: ./code
- name: Publish
run: yarn publish-sandboxes --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT}}@github.com/storybookjs/sandboxes.git --push --branch=main
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/generate-sandboxes-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
CLEANUP_SANDBOX_NODE_MODULES: true
steps:
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- uses: actions/checkout@v3
with:
ref: next
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Setup git user
run: |
git config --global user.name "Storybook Bot"
Expand All @@ -43,7 +43,7 @@ jobs:
run: yarn wait-on http://localhost:6001
working-directory: ./code
- name: Generate
run: yarn generate-sandboxes --local-registry --exclude=angular-cli/prerelease --debug
run: yarn generate-sandboxes --local-registry --debug
working-directory: ./code
- name: Publish
run: yarn publish-sandboxes --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT}}@github.com/storybookjs/sandboxes.git --push --branch=next
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 7.5.0-alpha.7

- Angular: Allow loading standalone directives - [#24448](https://github.com/storybookjs/storybook/pull/24448), thanks [@osnoser1](https://github.com/osnoser1)!
- Svelte: Fix docs generating when using `lang="ts"` or optional chaining - [#24096](https://github.com/storybookjs/storybook/pull/24096), thanks [@j3rem1e](https://github.com/j3rem1e)!
- Vite: Support Vite 5 - [#24395](https://github.com/storybookjs/storybook/pull/24395), thanks [@IanVS](https://github.com/IanVS)!

## 7.5.0-alpha.6

- Angular: Introduce argsToTemplate for property and event Bindings - [#24434](https://github.com/storybookjs/storybook/pull/24434), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"peerDependencies": {
"@preact/preset-vite": "*",
"typescript": ">= 4.3.x",
"vite": "^3.0.0 || ^4.0.0",
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0",
"vite-plugin-glimmerx": "*"
},
"peerDependenciesMeta": {
Expand Down
3 changes: 1 addition & 2 deletions code/builders/builder-vite/src/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { build as viteBuild, mergeConfig } from 'vite';
import type { Options } from '@storybook/types';
import { commonConfig } from './vite-config';

import { sanitizeEnvVars } from './envs';

export async function build(options: Options) {
const { build: viteBuild, mergeConfig } = await import('vite');
const { presets } = options;

const config = await commonConfig(options, 'build');
Expand All @@ -21,6 +21,5 @@ export async function build(options: Options) {
}).build;

const finalConfig = await presets.apply('viteFinal', config, options);

await viteBuild(await sanitizeEnvVars(options, finalConfig));
}
10 changes: 7 additions & 3 deletions code/builders/builder-vite/src/codegen-entries.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { loadPreviewOrConfigFile } from '@storybook/core-common';
import type { Options } from '@storybook/types';
import slash from 'slash';
import { normalizePath } from 'vite';
import { listStories } from './list-stories';

const absoluteFilesToImport = (files: string[], name: string) =>
const absoluteFilesToImport = async (
files: string[],
name: string,
normalizePath: (id: string) => string
) =>
files
.map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'/@fs/${normalizePath(el)}'`)
.join('\n');

export async function generateVirtualStoryEntryCode(options: Options) {
const { normalizePath } = await import('vite');
const storyEntries = await listStories(options);
const resolveMap = storyEntries.reduce<Record<string, string>>(
(prev, entry) => ({ ...prev, [entry]: entry.replace(slash(process.cwd()), '.') }),
Expand All @@ -18,7 +22,7 @@ export async function generateVirtualStoryEntryCode(options: Options) {
const modules = storyEntries.map((entry, i) => `${JSON.stringify(entry)}: story_${i}`).join(',');

return `
${absoluteFilesToImport(storyEntries, 'story')}
${await absoluteFilesToImport(storyEntries, 'story', normalizePath)}

function loadable(key) {
return {${modules}}[key];
Expand Down
3 changes: 2 additions & 1 deletion code/builders/builder-vite/src/codegen-importfn-script.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { normalizePath } from 'vite';

import type { Options } from '@storybook/types';
import { logger } from '@storybook/node-logger';

Expand All @@ -26,6 +26,7 @@ function toImportPath(relativePath: string) {
* @param stories An array of absolute story paths.
*/
async function toImportFn(stories: string[]) {
const { normalizePath } = await import('vite');
const objectEntries = stories.map((file) => {
const ext = path.extname(file);
const relativePath = normalizePath(path.relative(process.cwd(), file));
Expand Down
3 changes: 2 additions & 1 deletion code/builders/builder-vite/src/list-stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { glob } from 'glob';
import { normalizeStories, commonGlobOptions } from '@storybook/core-common';

import type { Options } from '@storybook/types';
import { normalizePath } from 'vite';

export async function listStories(options: Options) {
const { normalizePath } = await import('vite');

return (
await Promise.all(
normalizeStories(await options.presets.apply('stories', [], options), {
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-vite/src/optimizeDeps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';
import { normalizePath, resolveConfig } from 'vite';
import type { InlineConfig as ViteInlineConfig, UserConfig } from 'vite';
import type { Options } from '@storybook/types';
import { listStories } from './list-stories';
Expand Down Expand Up @@ -128,6 +127,7 @@ const asyncFilter = async (arr: string[], predicate: (val: string) => Promise<bo

export async function getOptimizeDeps(config: ViteInlineConfig, options: Options) {
const { root = process.cwd() } = config;
const { normalizePath, resolveConfig } = await import('vite');
const absoluteStories = await listStories(options);
const stories = absoluteStories.map((storyPath) => normalizePath(path.relative(root, storyPath)));
// TODO: check if resolveConfig takes a lot of time, possible optimizations here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import findCacheDirectory from 'find-cache-dir';
import { init, parse } from 'es-module-lexer';
import MagicString from 'magic-string';
import { ensureFile, writeFile } from 'fs-extra';
import { mergeAlias } from 'vite';
import type { Alias, Plugin } from 'vite';

const escapeKeys = (key: string) => key.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
Expand Down Expand Up @@ -38,6 +37,8 @@ const replacementMap = new Map([
*/
export async function externalGlobalsPlugin(externals: Record<string, string>) {
await init;
const { mergeAlias } = await import('vite');

return {
name: 'storybook:external-globals-plugin',
enforce: 'post',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
import { parse } from 'es-module-lexer';
import MagicString from 'magic-string';
import { createFilter } from 'vite';

const include = [/\.stories\.([tj])sx?$/, /(stories|story).mdx$/];
const filter = createFilter(include);
export async function injectExportOrderPlugin() {
const { createFilter } = await import('vite');

export const injectExportOrderPlugin = {
name: 'storybook:inject-export-order-plugin',
// This should only run after the typescript has been transpiled
enforce: 'post',
async transform(code: string, id: string) {
if (!filter(id)) return undefined;
const include = [/\.stories\.([tj])sx?$/, /(stories|story).mdx$/];
const filter = createFilter(include);

// TODO: Maybe convert `injectExportOrderPlugin` to function that returns object,
// and run `await init;` once and then call `parse()` without `await`,
// instead of calling `await parse()` every time.
const [, exports] = await parse(code);
return {
name: 'storybook:inject-export-order-plugin',
// This should only run after the typescript has been transpiled
enforce: 'post',
async transform(code: string, id: string) {
if (!filter(id)) return undefined;

if (exports.includes('__namedExportsOrder')) {
// user has defined named exports already
return undefined;
}
const s = new MagicString(code);
const orderedExports = exports.filter((e) => e !== 'default');
s.append(`;export const __namedExportsOrder = ${JSON.stringify(orderedExports)};`);
return {
code: s.toString(),
map: s.generateMap({ hires: true, source: id }),
};
},
};
// TODO: Maybe convert `injectExportOrderPlugin` to function that returns object,
// and run `await init;` once and then call `parse()` without `await`,
// instead of calling `await parse()` every time.
const [, exports] = await parse(code);

if (exports.includes('__namedExportsOrder')) {
// user has defined named exports already
return undefined;
}
const s = new MagicString(code);
const orderedExports = exports.filter((e) => e !== 'default');
s.append(`;export const __namedExportsOrder = ${JSON.stringify(orderedExports)};`);
return {
code: s.toString(),
map: s.generateMap({ hires: true, source: id }),
};
},
};
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { Plugin } from 'vite';
import { createFilter } from 'vite';
import MagicString from 'magic-string';

/**
* This plugin removes HMR `accept` calls in story files. Stories should not be treated
* as hmr boundaries, but vite has a bug which causes them to be treated as boundaries
* (https://github.com/vitejs/vite/issues/9869).
*/
export function stripStoryHMRBoundary(): Plugin {
export async function stripStoryHMRBoundary(): Promise<Plugin> {
const { createFilter } = await import('vite');

const filter = createFilter(/\.stories\.([tj])sx?$/);
return {
name: 'storybook:strip-hmr-boundary-plugin',
Expand Down
7 changes: 4 additions & 3 deletions code/builders/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';
import { loadConfigFromFile, mergeConfig } from 'vite';
import findCacheDirectory from 'find-cache-dir';
import type {
ConfigEnv,
Expand Down Expand Up @@ -41,6 +40,8 @@ export async function commonConfig(
_type: PluginConfigType
): Promise<ViteInlineConfig> {
const configEnv = _type === 'development' ? configEnvServe : configEnvBuild;
const { loadConfigFromFile, mergeConfig } = await import('vite');

const { viteConfigPath } = await getBuilderOptions<BuilderOptions>(options);

const projectRoot = path.resolve(options.configDir, '..');
Expand Down Expand Up @@ -80,8 +81,8 @@ export async function pluginConfig(options: Options) {
const plugins = [
codeGeneratorPlugin(options),
await csfPlugin(options),
injectExportOrderPlugin,
stripStoryHMRBoundary(),
await injectExportOrderPlugin(),
await stripStoryHMRBoundary(),
{
name: 'storybook:allow-storybook-dir',
enforce: 'post',
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-vite/src/vite-server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Server } from 'http';
import { createServer } from 'vite';
import type { Options } from '@storybook/types';
import { commonConfig } from './vite-config';
import { getOptimizeDeps } from './optimizeDeps';
Expand Down Expand Up @@ -29,5 +28,6 @@ export async function createViteServer(options: Options, devServer: Server) {

const finalConfig = await presets.apply('viteFinal', config, options);

const { createServer } = await import('vite');
return createServer(await sanitizeEnvVars(options, finalConfig));
}
40 changes: 40 additions & 0 deletions code/e2e-tests/framework-svelte.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable jest/no-disabled-tests */
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';

const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006';
const templateName = process.env.STORYBOOK_TEMPLATE_NAME;

test.describe('Svelte', () => {
test.skip(
// eslint-disable-next-line jest/valid-title
!templateName?.includes('svelte'),
'Only run this test on Svelte'
);

test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
});

test('JS story has auto-generated args table', async ({ page }) => {
const sbPage = new SbPage(page);

await sbPage.navigateToStory('stories/renderers/svelte/js-docs', 'docs');
const root = sbPage.previewRoot();
const argsTable = root.locator('.docblock-argstable');
await expect(argsTable).toContainText('Rounds the button');
});

test('TS story has auto-generated args table', async ({ page }) => {
// eslint-disable-next-line jest/valid-title
test.skip(!templateName?.endsWith('ts') || false, 'Only test TS story in TS templates');
const sbPage = new SbPage(page);

await sbPage.navigateToStory('stories/renderers/svelte/ts-docs', 'docs');
const root = sbPage.previewRoot();
const argsTable = root.locator('.docblock-argstable');
await expect(argsTable).toContainText('Rounds the button');
});
});
Loading