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

package.json type=script cause esbuild failed to bundle #2420

Closed
wenerme opened this issue Aug 30, 2022 · 1 comment
Closed

package.json type=script cause esbuild failed to bundle #2420

wenerme opened this issue Aug 30, 2022 · 1 comment

Comments

@wenerme
Copy link
Collaborator

wenerme commented Aug 30, 2022

due to type=script

# report content type as application/node
curl -I https://cdn.jsdelivr.net/npm/systemjs | grep content-type

esbuild failed to bundle systems, can not recongnize script type, bundled as json

✘ [ERROR] JSON does not support comments

    ../../node_modules/systemjs/dist/system.min.js:1:0:
      1 │ /*!
        ╵ ~~~

✘ [ERROR] Unexpected "!"

    ../../node_modules/systemjs/dist/system.min.js:4:0:
      4 │ !function(){function e(e,t){return(t||"")+" (SystemJS Error#"+e+" https://github.com/systemjs/sy...
        ╵ ^

✘ [ERROR] Unexpected "new"

    ../../node_modules/systemjs/dist/extras/dynamic-import-maps.min.js:1:0:
      1 │ new MutationObserver((function(e){for(var t=0;t<e.length;t++){var r=e[t];if("childList"===r.type...
        ╵ ~~~

✘ [ERROR] Unexpected "!"

    ../../node_modules/systemjs/dist/extras/module-types.min.js:1:0:
      1 │ !function(){function e(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(i,"/")),"/"===e[0]&&"/"===e[1]...
        ╵ ^

edit

the error is reported by vite, using esbuild only report

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

but vite some how failed when updating dependencies.

@guybedford
Copy link
Member

This seems like an esbuild issue. Very specifically, type "script" is useful as distinct from "commonjs" and "module" to distinguish CommonJS (which can be converted into ESM) from actual scripts (which can run on the web as scripts not ES modules, and without any conversion).

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

2 participants