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

support package.json type script #2506

Closed
wenerme opened this issue Aug 30, 2022 · 5 comments
Closed

support package.json type script #2506

wenerme opened this issue Aug 30, 2022 · 5 comments

Comments

@wenerme
Copy link

wenerme commented Aug 30, 2022

esbuild bundle systemjs

The "type" field must be set to either "commonjs" or "module".

xref systemjs/systemjs#2420

@evanw
Copy link
Owner

evanw commented Aug 30, 2022

The type field must be set to either commonjs or module for npm packages: https://nodejs.org/api/packages.html#type. The value script is not one of the valid values for that field. In addition, both esbuild and node only support those two module formats as input.

Edit: That said this is a warning, not an error, so you should still be able to build the package and have it do something. Warnings do not stop a build. Invalid values for the type field are just ignored by esbuild. You are welcome to silence warnings about invalid package.json files with --log-override:package.json=silent if you don't want to see them.

@sapphi-red
Copy link
Contributor

esbuild seems to load a file as JSON when sourcemap: true is set.

Here's the reproduction: https://stackblitz.com/edit/esbuild-template-3mtzn8?file=build.js

@sapphi-red
Copy link
Contributor

sapphi-red commented Aug 31, 2022

No, it wasn't. systemjs's file was incorrect.

system.min.js includes the following code...

//# sourceMappingURL=system.min.js

related: systemjs/systemjs#2421

@guybedford
Copy link
Contributor

@evanw JSPM supports a "type": "script" field to enable distinguishing scripts from modules in ESM CDN workflows, which turned out to be important when ESM is being optimized under different constraints (scripts and modules minify differently). I don't expect it to be supported elsewhere anytime soon, and a warning is no problem though.

@evanw
Copy link
Owner

evanw commented Aug 31, 2022

Ok. This is still not a module format that either node or esbuild supports, so I think the warning is ok. And with the investigation above about the JSON parsing problems (thanks for investigating this) it sounds like esbuild isn't doing anything wrong here. So I'm going to close this issue.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2022
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

4 participants