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

fast-glob fails with SyntaxError: Unexpected token from relocate-loader #438

Closed
egoist opened this issue Jun 21, 2019 · 10 comments
Closed
Labels
package issue priority Important issue or pull request to fast-track

Comments

@egoist
Copy link

egoist commented Jun 21, 2019

Found syntax error when bundling fast-glob:

Repro:

git clone https://gist.github.com/7f5cb8d054337c0b1a8217501305514f.git ncc-bug
cd ncc-bug
npm i
npx ncc build input.js

logs:

ncc: Version 0.20.1
ncc: Compiling file index.js
Error: Module build failed (from (webpack)/ncc/loaders/relocate-loader.js):
SyntaxError: Unexpected token (22:10)
    at Object.re.raise (evalmachine.<anonymous>:1:271099)
    at Object.V.unexpected (evalmachine.<anonymous>:1:227376)
    at Object.ee.parseIdent (evalmachine.<anonymous>:1:270282)
    at Object.parseIdent (evalmachine.<anonymous>:1:466467)
    at Object.parseIdent (evalmachine.<anonymous>:1:191232)
    at Object.ee.parsePropertyName (evalmachine.<anonymous>:1:266678)
    at Object.parsePropertyName (evalmachine.<anonymous>:1:4077)
    at Object.Q.parseClassElement (evalmachine.<anonymous>:1:241588)
    at Object.parseClassElement (evalmachine.<anonymous>:1:464657)
    at Object.parseClassElement (evalmachine.<anonymous>:1:187765)
Module build failed (from (webpack)/ncc/loaders/relocate-loader.js):
SyntaxError: Unexpected token (23:10)
    at Object.re.raise (evalmachine.<anonymous>:1:271099)
    at Object.V.unexpected (evalmachine.<anonymous>:1:227376)
    at Object.ee.parseIdent (evalmachine.<anonymous>:1:270282)
    at Object.parseIdent (evalmachine.<anonymous>:1:466467)
    at Object.parseIdent (evalmachine.<anonymous>:1:191232)
    at Object.ee.parsePropertyName (evalmachine.<anonymous>:1:266678)
    at Object.parsePropertyName (evalmachine.<anonymous>:1:4077)
    at Object.Q.parseClassElement (evalmachine.<anonymous>:1:241588)
    at Object.parseClassElement (evalmachine.<anonymous>:1:464657)
    at Object.parseClassElement (evalmachine.<anonymous>:1:187765)
    at compiler.close.n (evalmachine.<anonymous>:1:1539315)
    at _promise0.then._result0 (eval at create (evalmachine.<anonymous>:1:273321), <anonymous>:13:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)
@styfle
Copy link
Member

styfle commented Jun 22, 2019

Thanks! I was able to reproduce this issue.

@styfle styfle changed the title SyntaxError: Unexpected token from relocate-loader fast-glob fails with SyntaxError: Unexpected token from relocate-loader Jun 22, 2019
@reasonablytall
Copy link

I recently struggled with this same error trying to build fast-glob with browserify. Using the @babel/preset-env transform solved the problem, though I'm not sure which syntax transform solved it, or how you would do the same in webpack.

@guybedford
Copy link
Contributor

Fixed in 0.20.4 via #448.

@khawarizmus
Copy link

khawarizmus commented Jul 16, 2019

@guybedford @styfle I still face the same issue with version 0.20.4 but not sure which dependency is causing it

2019-07-16T10:24:54.555Z  Error: Module build failed (from /tmp/6f7bd075/.build-utils/.builder/node_modules/@zeit/ncc/dist/ncc/loaders/relocate-loader.js):
                          SyntaxError: Unexpected token (16:10)
                              at Object.re.raise (evalmachine.<anonymous>:1:266416)
                              at Object.z.unexpected (evalmachine.<anonymous>:1:222693)
                              at Object.ee.parseIdent (evalmachine.<anonymous>:1:265599)
                              at Object.parseIdent (evalmachine.<anonymous>:1:461728)
                              at Object.parseIdent (evalmachine.<anonymous>:1:186548)
                              at Object.ee.parsePropertyName (evalmachine.<anonymous>:1:261995)
                              at Object.parsePropertyName (evalmachine.<anonymous>:1:4333)
                              at Object.H.parseClassElement (evalmachine.<anonymous>:1:236905)
                              at Object.parseClassElement (evalmachine.<anonymous>:1:459918)
                              at Object.parseClassElement (evalmachine.<anonymous>:1:183081)
                          Module build failed (from /tmp/6f7bd075/.build-utils/.builder/node_modules/@zeit/ncc/dist/ncc/loaders/relocate-loader.js):
                          SyntaxError: Unexpected token (15:10)
                              at Object.re.raise (evalmachine.<anonymous>:1:266416)
                              at Object.z.unexpected (evalmachine.<anonymous>:1:222693)
                              at Object.ee.parseIdent (evalmachine.<anonymous>:1:265599)
                              at Object.parseIdent (evalmachine.<anonymous>:1:461728)
                              at Object.parseIdent (evalmachine.<anonymous>:1:186548)
                              at Object.ee.parsePropertyName (evalmachine.<anonymous>:1:261995)
                              at Object.parsePropertyName (evalmachine.<anonymous>:1:4333)
                              at Object.H.parseClassElement (evalmachine.<anonymous>:1:236905)
                              at Object.parseClassElement (evalmachine.<anonymous>:1:459918)
                              at Object.parseClassElement (evalmachine.<anonymous>:1:183081)
                              at compiler.close.n (evalmachine.<anonymous>:3:1350338)
                              at _promise0.then._result0 (eval at create (evalmachine.<anonymous>:1:349386), <anonymous>:13:1)
                              at <anonymous>

how can i debug this?

@khawarizmus
Copy link

My issue was that the deployment environment was still using the old version of ncc but not sure how to upgrade it to 0.20.4

@styfle
Copy link
Member

styfle commented Jul 16, 2019

If you're using ZEIT Now, you can try the latest builder @now/node@canary.

@khawarizmus
Copy link

@styfle it's building correctly after i tried canary but i am facing the following issue when trying to access the deployment URL

2019-07-16T16:07:02.708Z	8f2fbb84-5482-48bc-bd92-aeae76e8e330	Cannot find module '@nodelib/fs.stat'
2019-07-16T16:07:02.708Z	8f2fbb84-5482-48bc-bd92-aeae76e8e330	Did you forget to add it to "dependencies" in `package.json`?

@styfle
Copy link
Member

styfle commented Jul 16, 2019

@gimyboya Are you using yarn workspaces? There is a known bug we are working on with symlinks.

@khawarizmus
Copy link

Oh right, I am.
Should I switch to npm?

@styfle
Copy link
Member

styfle commented Jul 16, 2019

You can try referencing the path directly (probably require('fs') in your case) instead of the workspace symlink.

Follow this PR which will probably be fixed today or tomorrow https://github.com/zeit/now-builders/pull/765

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package issue priority Important issue or pull request to fast-track
Projects
None yet
Development

No branches or pull requests

5 participants