-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into bugfix/standalone-angular-directives
- Loading branch information
Showing
27 changed files
with
191 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 29 additions & 26 deletions
55
code/builders/builder-vite/src/plugins/inject-export-order-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }), | ||
}; | ||
}, | ||
}; | ||
} |
5 changes: 3 additions & 2 deletions
5
code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
code/frameworks/nextjs/src/head-manager/head-manager-provider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.