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

CommonJS build issue with namespace imports (process and os) #32029

Open
pelletier197 opened this issue Dec 3, 2024 · 3 comments
Open

CommonJS build issue with namespace imports (process and os) #32029

pelletier197 opened this issue Dec 3, 2024 · 3 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@pelletier197
Copy link

Describe the bug

When using a bundler to bundle a nodejs application to CommonJS, the bundling step fails because of star imports (namespace import) of node packages

import * as os from "node:os";
import * as process from "node:process";

Launching app fails because rollup will attempt to intorop the namespace defaults like so

const process__namespace = /* @__PURE__ */ _interopNamespaceDefault(process$1);

According to the rollup team, it's best to avoid star imports when possible. rollup/rollup#5559

You can basically achieve the same thing with import process from 'node:process.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 3, 2024
@xirzec
Copy link
Member

xirzec commented Dec 3, 2024

Hey @pelletier197 I'm a little confused about the context here, are you saying you have found this pattern used in our SDKs and that's causing issues bundling them?

@xirzec xirzec added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Dec 3, 2024
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

Hi @pelletier197. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@pelletier197
Copy link
Author

Yes, I was having exactly the same issue the person had in the issue mentionned there. I worked around using the fix they suggested output.externalLiveBindings.

I am building an electron application and the bundler is ViteJS.

I never had any problem with any library before importing the Azure SDK, and I confirmed that the problem went away when I removed it. After debugging the generated javascript, I narrowed down the issue to a global process import, and I found where this happened in the Azure SDK source code.

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants