Skip to content

Commit

Permalink
Merge branch 'next' into docs_fix_api_typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniebigodes committed Jun 27, 2024
2 parents 121989e + 25aa1dc commit 4cd2d46
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ async function loaderTransform(this: any, parentTrace: any, source?: string, inp
// modules.
sourceFileName: filename,
};
// Transpiles the broken syntax to the closest non-broken modern syntax.
// E.g. it won't transpile parameter destructuring in Safari
// which would break how we detect if the mount context property is used in the play function.
programmaticOptions.env.bugfixes = true;

if (!programmaticOptions.inputSourceMap) {
delete programmaticOptions.inputSourceMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ describe('PreviewWeb', () => {
openBlockLoadersGate({ l: 8 });
await waitForRender();

// Assert - renderToCanvas to be called the first time with initial args
// Assert - renderToCanvas to be called the first time with initial args and returned `loaded` value.
expect(projectAnnotations.renderToCanvas).toHaveBeenCalledOnce();
expect(projectAnnotations.renderToCanvas).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down
4 changes: 1 addition & 3 deletions code/lib/test/template/stories/before-each.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const meta = {
export default meta;

export const BeforeEachOrder = {
parameters: {
chromatic: { disable: true },
},
parameters: { chromatic: { disable: true } },
beforeEach() {
console.log('3 - [from story beforeEach]');
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from '@storybook/test';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
args: { label: 'Button' },
};

// We must not transpile destructuring, to make sure that we can analyze the context properties that are used in play.
// See: https://github.com/storybookjs/storybook/discussions/27389
export const DestructureNotTranspiled = {
parameters: { chromatic: { disable: true } },
async play() {
async function fn({ destructured }: { destructured: unknown }) {
console.log(destructured);
}
const match = fn.toString().match(/[^(]*\(([^)]*)/);
const params = match?.[0];
await expect(params).toContain('destructured');
},
};
2 changes: 1 addition & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function addEsbuildLoaderToStories(mainConfig: ConfigFile) {
loader: '${esbuildLoaderPath}',
options: {
loader: 'tsx',
target: 'es2015',
target: 'es2022',
},
},
// Handle MDX files per the addon-docs presets (ish)
Expand Down

0 comments on commit 4cd2d46

Please sign in to comment.