Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
1.98k stars 1.15k forks source link

Error building VSCode extension when @azure/identity-vscode is installed #29812

Open Power-Maverick opened 1 month ago

Power-Maverick commented 1 month ago

Describe the bug When I am adding the npm package @azure/identity-vscode to my VS Code extension Dataverse DevTools that is built using webpack; I am getting compile errors on keytar package

To Reproduce Steps to reproduce the behavior:

  1. Clone Dataverse DevTools and use the branch feat-enable-azure-login
  2. Run npm run compile

Expected behavior The package installation should not throw error.

Screenshots Error screenshot image

Additional context Error:

ERROR in ./node_modules/keytar/build/Release/keytar.node 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
 @ ./node_modules/keytar/lib/keytar.js 1:13-52
 @ ./node_modules/@azure/identity-vscode/dist-esm/identity-vscode/src/index.js 3:0-28 35:60-82
 @ ./src/login/login.ts 41:26-59
 @ ./src/helpers/dataverseHelper.ts 39:16-41
 @ ./src/extension.ts 36:26-62
github-actions[bot] commented 1 month ago

@KarishmaGhiya @maorleger

github-actions[bot] commented 1 month ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

maorleger commented 1 month ago

Hey @Power-Maverick - thanks for reaching out about this issue! I think you need to configure a node-loader for this as per https://github.com/atom/node-keytar/issues/59#issuecomment-279406165

However, I should warn you that we unfortunately hit a blocking issue that may prevent @azure/identity-vscode from working correctly (see https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TROUBLESHOOTING.md#troubleshoot-visual-studio-code-authentication-issues for more information)

While we resolve this internally we recommend using the az cli if possible. Hope this helps.

JLunda commented 1 month ago

I am also running into this issue when building a Vite/TypeScript/React application. From my limited understanding of how Vite is using the Rollup bundler under-the-hood, I think this issue may be related to the node loader for module resolution; however Vite's official documentation recommends that the moduleResolution setting be set to bundler: https://vitejs.dev/guide/migration#:~:text=If%20you%20are%20using%20TypeScript%2C%20make%20sure%20to%20set%20moduleResolution%3A%20%27bundler%27%20(or%20node16/nodenext)%20as%20Rollup%204%20requires%20it.%20Or%20you%20can%20set%20skipLibCheck%3A%20true%20instead.

I will try the node16 and nodenext values eventually and report back if any of those fix things for me, but it may be a while before I get to attempt this as project deadlines currently dictate what I am able to spend time experimenting on, unfortunately.

Power-Maverick commented 1 week ago

@maorleger do you have any anticipated date for the fix?

maorleger commented 1 week ago

@Power-Maverick - unfortunately not at this time, as we have upstream dependencies that the VSCodeCredential relies on and need to be fixed first.

I would recommend subscribing to https://github.com/Azure/azure-sdk-for-js/issues/22904 if you'd like to be notified of any updates or when an alternative solution is published.

cc @scottaddie

maorleger commented 1 week ago

Linking to the many threads on this:

https://github.com/microsoft/vscode-azure-account/issues/443

https://github.com/Azure/azure-sdk-for-js/issues/22904

@maorleger do you have any anticipated date for the fix?

Just to clarify, do you mean the fix to your original issue? There's no fix that needs to happen on the Azure SDK side, you likely need to add a node loader as per https://github.com/atom/node-keytar/issues/59#issuecomment-279406165

KarishmaGhiya commented 1 week ago

Hello folks, please don't use VisualStudioCredential, please use AzureCliCredential instead until we actually have a path forward, until there's a resolution on this - https://github.com/Azure/azure-sdk-for-js/issues/22904. This likely won't happen in the near future, since there are multiple teams involved in the effort. Look at the note on the Readme - https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#note-about-visualstudiocodecredential The current state of VisualStudioCredential is broken, and we have removed it from our DAC chain. cc: @Power-Maverick @JLunda