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

✨ Chore: Add Namespace builtins Vite Plugin by Natemoo-re #132

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

create-issue-branch[bot]
Copy link
Contributor

Original issue description

In order to ensure that all node builtin packages are properly prefixed with the node: prefix a good solution is using the Namespace Builtins Vite plugin from Natemoo-re on github

The best part you ask? well The best part is this is a super simple thing to setup, and should not be hard at all to include within the core integration as a Vite plugin! see the code example below!

import { defineConfig } from 'astro/config';
import { builtinModules as builtins } from 'node:module';

function namespaceBuiltins() {
  return {
    name: 'namespace-builtins',
    enforce: 'pre',
    resolveId(id) {
      if (id[0] === '.' || id[0] === '/') return;

      if (builtins.includes(id)) {
        return { id: `node:${id}`, external: true };
      }
    },
  };
}

// https://astro.build/config
export default defineConfig({
  vite: {
    plugins: [namespaceBuiltins()],
  },
});

Source (Stackblitz)

closes #130

@create-issue-branch create-issue-branch bot added chore enhancement New feature or request feat labels Jul 1, 2024
@create-issue-branch create-issue-branch bot changed the title Chore: Add Namespace builtins Vite Plugin by Natemoo-re ✨ Chore: Add Namespace builtins Vite Plugin by Natemoo-re Jul 1, 2024
@ghost
Copy link

ghost commented Jul 1, 2024

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2024-07-01 01:16:50 CET

@ghost
Copy link

ghost commented Jul 1, 2024

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2024-07-01 01:16:30 CET

@ghost
Copy link

ghost commented Jul 1, 2024

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2024-07-01 01:16:58 CET

@Adammatthiesen Adammatthiesen marked this pull request as ready for review July 1, 2024 01:06
@Adammatthiesen Adammatthiesen requested a review from a team July 1, 2024 01:07
@Adammatthiesen Adammatthiesen mentioned this pull request Jul 1, 2024
17 tasks
Copy link
Contributor

@jdtjenkins jdtjenkins left a comment

Choose a reason for hiding this comment

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

Yeah I love this, this is some top tier 🧠 shit

@Adammatthiesen
Copy link
Member

Yeah I love this, this is some top tier 🧠 shit

I thought it was a Cool find in the Astro Discord. I believe Florian was the one who linked it recently (to deal with a CF thing)

Copy link
Member

@dreyfus92 dreyfus92 left a comment

Choose a reason for hiding this comment

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

Finally, something small 🫡 LGTM ✅

@Adammatthiesen
Copy link
Member

!coauthor

Copy link

github-actions bot commented Jul 1, 2024

Co-authored-by: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com>
Co-authored-by: Jacob Jenkins <7649031+jdtjenkins@users.noreply.github.com>
Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>

@Adammatthiesen Adammatthiesen merged commit 99a9fe1 into main Jul 1, 2024
2 checks passed
@Adammatthiesen Adammatthiesen deleted the issue-0130 branch July 1, 2024 16:40
@create-issue-branch create-issue-branch bot mentioned this pull request Jul 23, 2024
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore enhancement New feature or request feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chore: Add Namespace builtins Vite Plugin by Natemoo-re
3 participants