-
Notifications
You must be signed in to change notification settings - Fork 5
[#387] Update Storybook nextConfigPath to support node modules #392
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
Merged
Conversation
This file contains hidden or 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
lorenyu
approved these changes
Apr 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautiful thanks
doshitan
added a commit
that referenced
this pull request
May 30, 2025
The container image was pinned to Node.js 20.18.1, see `Dockerfile`: ``` docker FROM node:20.18.1-bullseye-slim AS base ``` But attempting to use 20.18.1 to build Storybook, you encounter an error: ``` { column: 35, file: '/home/doshitan/projects/platform-test-nextjs/app/.storybook/main.mjs', length: 11, line: 29, lineText: ' nextConfigPath: path.resolve(import.meta.dirname, "../next.config.js"),', namespace: '', suggestion: '' } "import.meta" is not available with the "cjs" output format and will be empty SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook/main.mjs file. ``` This is due to a recent change[1] that switched to using `import.meta.dirname`, a feature of Node.js ESM loading, instead of the legacy `__dirname`. But automatic detection and loading a file as ESM is behind a feature flag until Node.js v20.19.0[2]. Thus breaking the Storybook build for the project's "official" Node 20.18.1 version and container workflow. So: - Update Node.js version to 20.19.2 - Add specific version requirement to `package.json`, which at least will display a warning to folks installing packages outside the container environment. - Use `package.json` specification to load the correct Node.js version in CI Which should help keep all the different environments in sync. And the new Node.js module behavior is the default in later versions as well, so might as well lean into it. [1] #392 [2] https://nodejs.org/en/blog/release/v20.19.0/#requireesm-is-now-enabled-by-default
doshitan
added a commit
that referenced
this pull request
May 30, 2025
The container image was pinned to Node.js 20.18.1, see `Dockerfile`: ``` docker FROM node:20.18.1-bullseye-slim AS base ``` But attempting to use 20.18.1 to build Storybook, you encounter an error: ``` { column: 35, file: '/home/doshitan/projects/platform-test-nextjs/app/.storybook/main.mjs', length: 11, line: 29, lineText: ' nextConfigPath: path.resolve(import.meta.dirname, "../next.config.js"),', namespace: '', suggestion: '' } "import.meta" is not available with the "cjs" output format and will be empty SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook/main.mjs file. ``` This is due to a recent change[1] that switched to using `import.meta.dirname`, a feature of Node.js ESM loading, instead of the legacy `__dirname`. But automatic detection and loading a file as ESM is behind a feature flag until Node.js v20.19.0[2]. Thus breaking the Storybook build for the project's "official" Node 20.18.1 version and container workflow. So: - Update Node.js version to 20.19.2 - Add specific version requirement to `package.json`, which at least will display a warning to folks installing packages outside the container environment. - Use `package.json` specification to load the correct Node.js version in CI Which should help keep all the different environments in sync. And the new Node.js module behavior is the default in later versions as well, so might as well lean into it. [1] #392 [2] https://nodejs.org/en/blog/release/v20.19.0/#requireesm-is-now-enabled-by-default
doshitan
added a commit
that referenced
this pull request
May 30, 2025
The container image was pinned to Node.js 20.18.1, see `Dockerfile`: ``` docker FROM node:20.18.1-bullseye-slim AS base ``` But attempting to use 20.18.1 to build Storybook, you encounter an error: ``` { column: 35, file: '/home/doshitan/projects/platform-test-nextjs/app/.storybook/main.mjs', length: 11, line: 29, lineText: ' nextConfigPath: path.resolve(import.meta.dirname, "../next.config.js"),', namespace: '', suggestion: '' } "import.meta" is not available with the "cjs" output format and will be empty SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook/main.mjs file. ``` This is due to a recent change[1] that switched to using `import.meta.dirname`, a feature of Node.js ESM loading, instead of the legacy `__dirname`. But automatic detection and loading a file as ESM is behind a feature flag until Node.js v20.19.0[2]. Thus breaking the Storybook build for the project's "official" Node 20.18.1 version and container workflow. So: - Update Node.js version to 20.19.2 - Add specific version requirement to `package.json`, which at least will display a warning to folks installing packages outside the container environment. - Use `package.json` specification to load the correct Node.js version in CI Which should help keep all the different environments in sync. And the new Node.js module behavior is the default in later versions as well, so might as well lean into it. [1] #392 [2] https://nodejs.org/en/blog/release/v20.19.0/#requireesm-is-now-enabled-by-default
doshitan
added a commit
that referenced
this pull request
May 30, 2025
The container image was pinned to Node.js 20.18.1, see `Dockerfile`: ``` docker FROM node:20.18.1-bullseye-slim AS base ``` But attempting to use 20.18.1 to build Storybook, you encounter an error: ``` { column: 35, file: '/home/doshitan/projects/platform-test-nextjs/app/.storybook/main.mjs', length: 11, line: 29, lineText: ' nextConfigPath: path.resolve(import.meta.dirname, "../next.config.js"),', namespace: '', suggestion: '' } "import.meta" is not available with the "cjs" output format and will be empty SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook/main.mjs file. ``` This is due to a recent change[1] that switched to using `import.meta.dirname`, a feature of Node.js ESM loading, instead of the legacy `__dirname`. But automatic detection and loading a file as ESM is behind a feature flag until Node.js v20.19.0[2]. Thus breaking the Storybook build for the project's "official" Node 20.18.1 version and container workflow. So: - Update Node.js version to 20.19.2 - Add specific version requirement to `package.json`, which at least will display a warning to folks installing packages outside the container environment. - Use `package.json` specification to load the correct Node.js version in CI Which should help keep all the different environments in sync. And the new Node.js module behavior is the default in later versions as well, so might as well lean into it. [1] #392 [2] https://nodejs.org/en/blog/release/v20.19.0/#requireesm-is-now-enabled-by-default
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
Resolves #387
Changes
Context for reviewers
Originally made an update to Storybook in #388 meant to address #387. Making these changes caused issues in platform-test-nextjs.
The steps taken to resolve are in this PR.
Testing
Making this change in platform-test-nextjs resulted in a successful app build (save for a vulnerability scan). This change also follows Node.js documentation on what they recommend to use in place of
__dirname
.