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

Imports from stdio entrypoint don't have a namespace set #3726

Open
MariusVatasoiu opened this issue Apr 11, 2024 · 0 comments
Open

Imports from stdio entrypoint don't have a namespace set #3726

MariusVatasoiu opened this issue Apr 11, 2024 · 0 comments

Comments

@MariusVatasoiu
Copy link

Imports used in the stdio.contents don't get a namespace set.
This is a small code snippet where I have a plugin that needs the namespace porperty.

I thought the namespace is set based only on the import's path, so shouldn't be any difference between stdio and physical entryPoints. Unless, there are other limitations.

import * as esbuild from "npm:esbuild@0.20.2";

const myPlugin = {
  name: "myPlugin",
  setup(build) {
    build.onResolve({ filter: /.*?/ }, (args) => {
      console.log(args);       
    //    args.namespace is empty for both imports used in the stdio content
    //    {
    //     path: "https://deno.land/std@0.185.0/bytes/mod.ts",
    //     importer: "<stdin>",
    //     namespace: "",
    //     resolveDir: "/Users/..",
    //     kind: "import-statement",
    //     pluginData: undefined
    //     }
    
    //     {
    //     path: "./main.ts",
    //     importer: "<stdin>",
    //     namespace: "",
    //     resolveDir: "/Users/...",
    //     kind: "import-statement",
    //     pluginData: undefined
    //     }
       
    });
  },
};

const result = await esbuild.build({
  stdin: {
    contents: `
    import "https://deno.land/std@0.185.0/bytes/mod.ts";
    import "./main.ts";       
    `,
    resolveDir: Deno.cwd(),
  },
  plugins: [myPlugin],
  outfile: "./test.bundle.js",
  bundle: true,
  format: "esm",
});

console.log(result.outputFiles);

esbuild.stop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant