Skip to content

fix: Compatibility issue between Common/ES Modules #83

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"watch": "yarn workspace storybook-framework-qwik watch",
"build": "yarn workspace storybook-framework-qwik build",
"lint-all": "yarn workspaces foreach run fmt.check && yarn workspaces foreach run lint",
"storybook": "yarn workspace qwik-app storybook",
"storybook": "yarn workspace qwik-lib storybook",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please revert this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing mb

"fmt-all": "yarn workspaces foreach run fmt",
"fmt": "prettier --write .",
"fmt.check": "prettier --check .",
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook-framework-qwik/preset.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// This file seems to only be necessary for Windows
module.exports = require("./dist/preset");
export * from "./dist/preset.js"
11 changes: 4 additions & 7 deletions packages/storybook-framework-qwik/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import { qwikDocgen } from "./docs/qwik-docgen.js";
import { StorybookConfig } from "./types.js";
import { dirname, join } from "path";
import { createRequire } from "module";

const require = createRequire(import.meta.url);
const wrapForPnP = (input: string) =>
dirname(require.resolve(join(input, "package.json")));
import { fileURLToPath } from "url";

export const core: StorybookConfig["core"] = {
builder: wrapForPnP("@storybook/builder-vite"),
renderer: wrapForPnP("storybook-framework-qwik"),
builder: "@storybook/builder-vite",
renderer: "storybook-framework-qwik",
};

export const viteFinal: StorybookConfig["viteFinal"] = async (
Expand Down Expand Up @@ -54,7 +51,7 @@ export const viteFinal: StorybookConfig["viteFinal"] = async (

export const previewAnnotations: StorybookConfig["previewAnnotations"] = (
entry = [],
) => [...entry, require.resolve("storybook-framework-qwik/preview.js")];
) => [...entry, join(dirname(fileURLToPath(import.meta.url)), "../preview.js")];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to make yarn workspace qwik-app storybook fail to load for me

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5:00:14 PM [vite] Pre-transform error: Failed to resolve import "/Users/benjaminkindle/Developer/Web/storybook-framework-qwik/packages/storybook-framework-qwik/preview.js" from "/virtual:/@storybook/builder-vite/vite-app.js". Does the file exist?
5:00:14 PM [vite] Internal server error: Failed to resolve import "/Users/benjaminkindle/Developer/Web/storybook-framework-qwik/packages/storybook-framework-qwik/preview.js" from "/virtual:/@storybook/builder-vite/vite-app.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /virtual:/@storybook/builder-vite/vite-app.js:7:81

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice i will take a look ASAP


export const previewHead = (head: string) => {
return `${head} <script>${QWIK_LOADER}</script>`;
Expand Down
Loading