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

parameters.fileName is null #142

Closed
wild-nyankoman opened this issue Nov 8, 2021 · 1 comment · Fixed by #216
Closed

parameters.fileName is null #142

wild-nyankoman opened this issue Nov 8, 2021 · 1 comment · Fixed by #216

Comments

@wild-nyankoman
Copy link

hello.
As you can see in the screenshot, parameters.fileName is null.
Add-ons that depend on'fileName' won't work.
(e.g. storybook-addon-playwright )

image

story source

const Template: ComponentStory<typeof Button> = function (args) {
  console.log(arguments);
  return <Button {...args} />;
};

I have patched codegen-iframe-script.js as follows.

add this code in line 56.

        const cwd = process.cwd();
        const resolveMap = storyEntries.reduce((prev, entry) => ({...prev, [entry]: entry.replace(cwd, '.') }), {});
        const modules = storyEntries.map((entry, i) => `${JSON.stringify(entry)}: story_${i}`).join(',')
        const loadable = `
        (() => {
          const loadable = function(key) {
            return {${modules}}[key];
          };
          Object.assign(loadable, {
            keys: () => (${JSON.stringify(Object.keys(resolveMap))}),
            resolve: (key) => (${JSON.stringify(resolveMap)}[key])
          });
          return loadable;
        })()`;

change line 112.

    configure(${loadable}, { hot: import.meta.hot }, false); // not sure if the import.meta.hot thing is correct
    `.trim();
        return code;
    };
@joshwooding
Copy link
Member

While this is still broken when storyStoreV7 is not enabled. When it is enabled it works as expected :)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants