Skip to content

Commit

Permalink
fix(import-meta): import process from node:process for node compa…
Browse files Browse the repository at this point in the history
…tible builds (deno) (#2225)
  • Loading branch information
littledivy authored Mar 8, 2024
1 parent c4b619c commit 4ecd31f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rollup/plugins/import-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ export function importMeta(nitro: Nitro): Plugin {
nitro.options.node && isEntry
? "_import_meta_url_"
: '"file:///_entry.js"';
const envImport = nitro.options.node
? "import process from 'node:process';"
: "";
const env = nitro.options.node ? "process.env" : "{}";
const ref = "globalThis._importMeta_";
const stub = `{url:${url},env:${env}}`;
const stubInit = isEntry ? `${ref}=${stub};` : `${ref}=${ref}||${stub};`;

return {
code: stubInit + code,
code: envImport + stubInit + code,
map: null,
};
},
Expand Down

0 comments on commit 4ecd31f

Please sign in to comment.