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

Building with 3.0.2 fails on Windows if there's a build-figma-plugin.ui.cjs file in the repo #205

Open
fwextensions opened this issue Nov 2, 2023 · 10 comments · Fixed by #211
Labels
bug Something isn't working windows

Comments

@fwextensions
Copy link

I think this is #77 all over again. The build-figma-plugin.ui.cjs file is just this:

module.exports = (buildOptions) => ({
	...buildOptions,
	keepNames: true,
});

When it's in the main directory, npm run build fails with this error:

info Typechecking...
success Typechecked in 2.048s
info Building...
error esbuild error
    Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
npm ERR! Lifecycle script `build` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: fwidgets-test-plugin@0.0.1 
npm ERR!   at location: C:\...\test 

When the config file is removed, the build works, but the plugin doesn't, because it needs to pass keepNames: true to esbuild. (As an aside, it would be nice if this sort of config, as well as the manifest, could be passed on the command line, which would then avoid this problem.)

@yuanqing
Copy link
Owner

yuanqing commented Nov 2, 2023

I don’t have a Windows machine so I can’t properly debug this. Would the fix be to specify keepNames: true when esbuild detects that it is running in Windows?

@fwextensions
Copy link
Author

fwextensions commented Nov 2, 2023

No, that was just something I happened to need to add for a library I'm working on. The issue is having any config file at all on Windows. Having a config worked in 2.6.1, but failed when I updated.

I haven't investigated, but based on this comment, something may have been fixed previously: #77 (comment)

@fwextensions
Copy link
Author

Just to confirm, the contents of the build-* files doesn't matter. It can be completely empty. Just its existence causes the error, since it occurs while trying to load the file, before it's executed.

@janweigel
Copy link

janweigel commented Nov 20, 2023

I have the same problem here on a Windows machine.
If there exists any build-figma-plugin.main.js or build-figma-plugin.ui.js config file then the build fails with:
error esbuild error
Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'

The content of the config file does not matter.

There seems to be a problem with resolving the path on Windows.
Building is not possible until this is fixed.

@yuanqing yuanqing added bug Something isn't working windows labels Dec 9, 2023
@fwextensions
Copy link
Author

Anything we can do to help fix this? I was just thinking about trying to add some values via a .env file, as described in this comment, but there's no way to add a build config on Windows due to this bug.

@yuanqing
Copy link
Owner

@fwextensions @janweigel – Happy to review and merge a PR if any of you would like to work on a fix!

From the error message you shared, my suspicion is that the absolute path returned by globby in this line of code in the build-bundles-async.ts file is the root cause of the problem:

const filePaths = await globby(configGlobPattern, { absolute: true })

Is the fix here to add a file:// prefix to the path when running on Windows?

TheUltDev added a commit to TheUltDev/create-figma-plugin that referenced this issue Jan 1, 2024
@TheUltDev TheUltDev mentioned this issue Jan 1, 2024
@TheUltDev
Copy link
Contributor

@yuanqing yes, that's what was needed.
I tested on my Windows machine, this is working for me: #211

@XmlmXmlmX
Copy link

Same problem here (Windows 10):

> build-figma-plugin --typecheck --minify

info Typechecking...
success Typechecked in 1.114s
info Building...
error esbuild error
    Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

@kikobr
Copy link

kikobr commented Feb 28, 2024

i'm having the same issue here on Windows 11. i'm blocked... any ideas how to fix this?

info Building... error esbuild error Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' success Typechecked in 2.726s info Watching...

@TheUltDev
Copy link
Contributor

@kikobr #211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants