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

Module parse failed: Unexpected token (473:30) #596

Closed
ohardy opened this issue Jan 21, 2019 · 24 comments
Closed

Module parse failed: Unexpected token (473:30) #596

ohardy opened this issue Jan 21, 2019 · 24 comments
Labels

Comments

@ohardy
Copy link

ohardy commented Jan 21, 2019

Bug Report

Clean install of last version of docz. When I run docz dev, I got:

./node_modules/docz/dist/index.m.js 473:30
Module parse failed: Unexpected token (473:30)
You may need an appropriate loader to handle this file type.
| async function loadFromImports(path) {
|     // tslint:disable-next-line
>     const { imports } = await import('~imports');
|     const { default: Component$$1, getInitialData } = await imports[path]();
|     const ExportedComponent = props => (createElement(AsyncComponent, Object.assign({}, props, { as: Component$$1 || 'div', getInitialData: getInitialData })));
 @ ./node_modules/docz-theme-default/dist/index.m.js 39:0-72 243:12-16 374:35-39 466:34-45 467:8-12 511:25-29 552:50-54 640:16-27 643:41-45 942:20-24 1024:28-39 1098:16-27 1490:33-44 1601:16-27 1872:16-27 1935:29-40 2029:45-56 2040:25-36 2041:8-18 2073:16-21
 @ ./.docz/app/root.jsx
 @ ./.docz/app/index.jsx
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@babel/polyfill/lib/index.js ./.docz/app/index.jsx

I can't share a project link.

I check webpack aliases with:

modifyBundlerConfig : (config) => {
    console.log(config.resolve.alias);
    return config;
}),

and ~imports is present.

Thanks in advance

@dfee
Copy link

dfee commented Jan 22, 2019

Definitely getting the same issue. I can share my project.

https://github.com/dfee/rbx/

@dfee
Copy link

dfee commented Jan 22, 2019

I can tell you @pedronauck exactly where the problem is:

The incompatibility lies with an upgrade of [email protected] -> [email protected].

diff --git b/package-lock.json a/package-lock.json
index f0a5074..054340d 100644
--- b/package-lock.json
+++ a/package-lock.json
@@ -1787,10 +1787,13 @@
       "dev": true
     },
     "acorn-dynamic-import": {
-      "version": "4.0.0",
-      "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
-      "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
-      "dev": true
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz",
+      "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==",
+      "dev": true,
+      "requires": {
+        "acorn": "^5.0.0"
+      }
     },
     "acorn-globals": {
       "version": "4.3.0",
@@ -16621,17 +16624,17 @@
       "dev": true
     },
     "webpack": {
-      "version": "4.29.0",
-      "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.29.0.tgz",
-      "integrity": "sha512-pxdGG0keDBtamE1mNvT5zyBdx+7wkh6mh7uzMOo/uRQ/fhsdj5FXkh/j5mapzs060forql1oXqXN9HJGju+y7w==",
+      "version": "4.28.4",
+      "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.28.4.tgz",
+      "integrity": "sha512-NxjD61WsK/a3JIdwWjtIpimmvE6UrRi3yG54/74Hk9rwNj5FPkA4DJCf1z4ByDWLkvZhTZE+P3C/eh6UD5lDcw==",
       "dev": true,
       "requires": {
         "@webassemblyjs/ast": "1.7.11",
         "@webassemblyjs/helper-module-context": "1.7.11",
         "@webassemblyjs/wasm-edit": "1.7.11",
         "@webassemblyjs/wasm-parser": "1.7.11",
-        "acorn": "^6.0.5",
-        "acorn-dynamic-import": "^4.0.0",
+        "acorn": "^5.6.2",
+        "acorn-dynamic-import": "^3.0.0",
         "ajv": "^6.1.0",
         "ajv-keywords": "^3.1.0",
         "chrome-trace-event": "^1.0.0",
@@ -16652,12 +16655,6 @@
         "webpack-sources": "^1.3.0"
       },
       "dependencies": {
-        "acorn": {
-          "version": "6.0.5",
-          "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.5.tgz",
-          "integrity": "sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg==",
-          "dev": true
-        },
         "schema-utils": {
           "version": "0.4.7",
           "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz",

@lucalanca
Copy link

If someone is stuck on this, and following @dfee's hints, this seems to fix it:

npm i -D [email protected]

@pedronauck
Copy link
Member

Thanks @dfee, this is already fixed on v0.14 that will be launch. Can I close this issue?

@sunkeysun
Copy link

sunkeysun commented Jan 30, 2019

npm install docz@latest now default to 0.13.7, please release 0.14 to resolve this problem in latest version.

@swyxio
Copy link
Contributor

swyxio commented Jan 30, 2019

fyi pedro is currently sick and will get back to this in a few days (i dont speak for him but just relaying the info)

1 similar comment
@swyxio
Copy link
Contributor

swyxio commented Jan 30, 2019

fyi pedro is currently sick and will get back to this in a few days (i dont speak for him but just relaying the info)

@wilsson
Copy link

wilsson commented Feb 3, 2019

If someone is stuck on this, and following @dfee's hints, this seems to fix it:

npm i -D [email protected]

Thanks, waiting v0.14

@swyxio swyxio pinned this issue Feb 4, 2019
@lejoe
Copy link

lejoe commented Feb 5, 2019

+1 here.

mentionned trick works but as it's on our CI that this fails it really hurts to put this hack as a step in the build :(

@CyberNika
Copy link

when will v0.14 be released?

@swyxio
Copy link
Contributor

swyxio commented Feb 20, 2019

hi @dfee and everyone here with webpack issues

turns out webpack 4.29 has had some wacky npm dependency issues i dont fully understand. just saw this in an unrelated project i'm helping out on as well: react-static/react-static#1027 (comment)

its a mess. use yarn as much as possible.

@davixyz
Copy link

davixyz commented Feb 22, 2019

We are facing this issue :(

@giulianok
Copy link

Same here

@bichotll
Copy link

bichotll commented Mar 6, 2019

Same here.
For the record: I actually don't have Webpack installed in my project.

@ghost
Copy link

ghost commented Mar 6, 2019

@bichotll I think they mean you need to update the version inside node_modules/docz-core. I've been using this cd node_modules/docz-core && npm i -D [email protected] && cd .. && cd ..

@bichotll
Copy link

bichotll commented Mar 6, 2019

@mattietea oh! thanks for the heads up! 👍

@dkvirus
Copy link

dkvirus commented Mar 11, 2019

npm i -D [email protected] is ok. But it can be confusing for the novice. Look forward to releasing 0.14 soon.

@timbergus
Copy link

Thanks a lot for your help. It looks like everything works with Yarn, and the problem appears only with NPM and the WebPack issue. I have an empty project for testing with only a package.json and using the instructions from @mattietea, I have managed to make docz work, but now I have an error in the browser. I think I will use Yarn until the [email protected] update.

Screenshot 2019-03-12 11 44 30

@davixyz
Copy link

davixyz commented Mar 13, 2019

@timbergus I had the same issue, it gets solve if you lock [email protected]. I opened an issue around this:
bublejs/buble#189

@loopmode
Copy link

loopmode commented Mar 22, 2019

The [email protected] trick doesn't work for me. In my case, I'm getting a bunch of errors for CSS files that are being imported.


Oh, apologies for being such a noob.. It's my first hour of using docz :)
I simply needed docz-plugin-css and all is well, sorry for the confusion!

@pedronauck
Copy link
Member

Docz is using [email protected], this bug keeps showing with this version?

@mateuszkocz
Copy link

mateuszkocz commented Mar 24, 2019

Just got the same problem on a fresh installation. For me, the issue got solved by creating the project again with Yarn. npm installation failed with the error similar to what @ohardy posted.

Reproduction of an error:

npm init -y
npm install -D docz@next docz-theme-default@next
# Add scripts to the package.json from the documentation.
npm run docz:dev

Reproduction of a success:

npm init -y
yarn add docz@next docz-theme-default@next --dev
# Add scripts to the package.json from the documentation.
yarn run docz:dev

Full error:

 ERROR  Failed to compile with 2 errors                                                                       1:39:50 PM

 error  in ./node_modules/docz/dist/index.esm.js

Module parse failed: Unexpected token (15:38)
You may need an appropriate loader to handle this file type.
| import { MDXProvider } from '@mdx-js/tag';
|
> const BasePlayground = loadable(() => import('./chunk.esm2.js'));
| const Playground = props => typeof window !== 'undefined' ? (createElement(Suspense, { fallback: null },
|     createElement(BasePlayground, Object.assign({}, props)))) : null;

 @ ./.docz/app/root.jsx 9:0-59 16:2-15 18:19-23 25:25-31
 @ ./.docz/app/index.jsx
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./.docz/app/index.jsx

 error  in ./node_modules/docz-theme-default/dist/index.esm.js

Module parse failed: Unexpected token (245:30)
You may need an appropriate loader to handle this file type.
| `;
|
> const CodeMirror = lazy(() => import('./chunk.esm2.js'));
| const getLanguage = (children) => {
|     const defaultLanguage = 'jsx';

 @ ./.docz/app/root.jsx 11:0-39 17:29-34
 @ ./.docz/app/index.jsx
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./.docz/app/index.jsx

Versions:

  • docz and docz-theme-default 1.0.0-rc.3
  • node 11.6.0
  • npm 6.5.0
  • yarn 1.12.1

Hope this might help in some way.

jwijay added a commit to stencila/schema that referenced this issue Mar 25, 2019
Note: reads mdx files, not md.
docz-core dependency needs specific webpack version: doczjs/docz#596 (comment)
`cd node_modules/docz-core && npm i -D [email protected] && cd .. && cd ..`

Then run `npm run docz:build`, `npm run docz:dev`.

Signed-off-by: Jackie Wijaya <[email protected]>
@cupofjoakim
Copy link

@pedronauck to answer your question, I'm still having this issue on rc7 with webpack 4.29.6. Npm support is sadly a must for my organization, otherwise the workaround above does work.

@pedronauck
Copy link
Member

Closed in favor of #704, the answer is there.

@pedronauck pedronauck unpinned this issue Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests