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

Prevent astro:content from depending on Node builtins #6537

Merged
merged 3 commits into from
Mar 13, 2023

Conversation

matthewp
Copy link
Contributor

Changes

  • Fixes issue where non-Node runtimes were breaking when using astro:content due to the Node dependency that --experimental-assets has.

Testing

  • In the content collections test, add a plugin that verifies that no Node builtins are depended on in the build.

Docs

N/A, bug fix

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2023

🦋 Changeset detected

Latest commit: c255e86

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 13, 2023
Comment on lines 231 to 238
generateBundle() {
const nodeModules = ['node:fs', 'node:url', 'node:worker_threads', 'node:path'];
nodeModules.forEach(name => {
const mod = this.getModuleInfo(name);
if(mod) {
throw new Error(`Node builtins snuck in: ${name}`)
}
});
Copy link
Member

Choose a reason for hiding this comment

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

This is very smart! I wonder if this would be useful as a more general (not CC-specific) test as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally. I remember multiple breaking bugs with the Markdown plugin a while back too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can move this into test-utils so other tests can use it more easily

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created a test-plugins.js file so we can put more stuff like this if needed.

Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

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

runtime funtime 🙌

@matthewp matthewp merged commit 6a7cf07 into main Mar 13, 2023
@matthewp matthewp deleted the astro-content-node branch March 13, 2023 19:36
@astrobot-houston astrobot-houston mentioned this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants