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

Frame-based errors for asset relocator parser #332

Open
igorklopov opened this issue Mar 31, 2019 · 8 comments
Open

Frame-based errors for asset relocator parser #332

igorklopov opened this issue Mar 31, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@igorklopov
Copy link
Contributor

require('express');
await fn();

also

require('express');
{

also

require('express');
break;
@igorklopov igorklopov changed the title require('express') + any syntax error causes unhandled rejection require('express') + any syntax error = unhandled rejection Mar 31, 2019
@guybedford
Copy link
Contributor

Are you sure this is running the latest ncc with the fix from #324 (ncc 0.17.0). I just tried this on the latest build and the errors seem to display correctly here.

@igorklopov
Copy link
Contributor Author

igorklopov commented Mar 31, 2019

@guybedford I confirm. Just checked again. This script reproduces it from scratch:

npm init -y
npm i @zeit/ncc@0.17.0
echo $"require('express');\nbreak;" > index.js
./node_modules/.bin/ncc build index.js

@igorklopov
Copy link
Contributor Author

igorklopov commented Mar 31, 2019

+ @zeit/ncc@0.17.0
added 1 package and audited 1 package in 1.25s
found 0 vulnerabilities

Error: Hash: 341323a9f53fee3ce68b
Version: webpack 5.0.0-alpha.9
Time: 90ms
Built at: 03/31/2019 8:37:41 PM
   Asset      Size  Chunks  Chunk Names
index.js  2.04 KiB   {404}  main
Entrypoint main = index.js
[950] ./index.js 721 bytes {404} [built] [failed] [1 error]

ERROR in ./index.js
Module build failed (from ./node_modules/@zeit/ncc/dist/ncc/loaders/relocate-loader.js):
SyntaxError: Unsyntactic break (2:0)
    at Object.re.raise (evalmachine.<anonymous>:1:179108)
    at Object.Q.parseBreakContinueStatement (evalmachine.<anonymous>:1:140053)
    at Object.Q.parseStatement (evalmachine.<anonymous>:1:138027)
    at Object.parseStatement (evalmachine.<anonymous>:1:30297)
    at Object.parseStatement (evalmachine.<anonymous>:1:575710)
    at Object.Q.parseTopLevel (evalmachine.<anonymous>:1:136703)
    at Object.parse (evalmachine.<anonymous>:1:133032)
    at Function.parse (evalmachine.<anonymous>:1:133799)
    at Object.e.exports (evalmachine.<anonymous>:1:466043)

    at compiler.close.n (evalmachine.<anonymous>:3:1349901)
    at _promise0.then._result0 (eval at create (evalmachine.<anonymous>:1:349386), <anonymous>:13:1)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

@igorklopov
Copy link
Contributor Author

igorklopov commented Mar 31, 2019

However i expect

ERROR in ./index.js 2:0
Module parse failed: Unsyntactic break (2:0)
You may need an appropriate loader to handle this file type.
| require('express');
> break;
|

    at compiler.close.n (evalmachine.<anonymous>:3:1349901)
    at _promise0.then._result0 (eval at create (evalmachine.<anonymous>:1:349386), <anonymous>:13:1)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

@igorklopov
Copy link
Contributor Author

@guybedford btw it works well with 0.16.1. This one prints a correct message:

npm init -y
npm i @zeit/ncc@0.16.1
echo $"require('express');\nbreak;" > index.js
./node_modules/.bin/ncc build index.js

@guybedford
Copy link
Contributor

Ahh I see. Yes the asset relocator does a parse, but does not provide syntax highlighted errors. Marking as an enhancement.

@guybedford guybedford added the enhancement New feature or request label Mar 31, 2019
@igorklopov
Copy link
Contributor Author

Thanks! Yeah, it is not unhandled rejection in 0.17.0, only wrong message.

@igorklopov igorklopov changed the title require('express') + any syntax error = unhandled rejection require('express') + any syntax error = unusual message Mar 31, 2019
@guybedford guybedford changed the title require('express') + any syntax error = unusual message Frame-based errors for asset relocator parser May 15, 2019
@guybedford
Copy link
Contributor

Implemented in vercel/webpack-asset-relocator-loader#63.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants