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

webpack-loader with object rest spread plugin fails parsing #225

Closed
dan-lee opened this issue May 30, 2018 · 7 comments
Closed

webpack-loader with object rest spread plugin fails parsing #225

dan-lee opened this issue May 30, 2018 · 7 comments
Assignees

Comments

@dan-lee
Copy link

dan-lee commented May 30, 2018

When trying to run sucrase with the webpack-loader and webpack-object-rest-spread-plugin I get the following error:

ERROR in ./src/Main.jsx
Module parse failed: this.applyPluginsBailResult is not a function
You may need an appropriate loader to handle this file type.
TypeError: this.applyPluginsBailResult is not a function

Versions used:

webpack: 4.8.3
sucrase: 2.2.0
@sucrase/webpack-loader: 1.0.2,
@sucrase/webpack-object-rest-spread-plugin: 1.0.0
@alangpierce
Copy link
Owner

Thanks for reporting. Since you're on webpack 4, I think object rest/spread should actually work without webpack-object-rest-spread-plugin. I wrote that plugin before webpack 4 came out, and it's still needed on 3 or earlier. Could you try removing that plugin and see if it works and that you can still have object rest/spread in your code?

I'll update the docs to say that webpack-object-rest-spread-plugin is not needed in webpack 4. It looks like webpack 4 changed enough to break the plugin, so I'll also see if I can make it print a warning and do nothing if it detects that you're on webpack 4.

@alangpierce alangpierce self-assigned this May 30, 2018
@dan-lee
Copy link
Author

dan-lee commented May 30, 2018

Oh yeah, it works without. I just blindly assumed it was necessary.
Thank you, and keep up the nice project :)

@dan-lee dan-lee closed this as completed May 30, 2018
@alangpierce
Copy link
Owner

Thanks, glad to hear! I'll actually reopen to track the task of updating the docs and maybe adding a runtime check.

@alangpierce alangpierce reopened this May 30, 2018
@iki
Copy link

iki commented Jun 6, 2018

@alangpierce Actually, I get the above error with webpack4, typescript and webpack-object-rest-spread-plugin. However, if I remove the spread plugin, I get error on the first spread operator:

ERROR in ./src/containers/App.tsx
Module build failed: SyntaxError: ./src/containers/App.tsx: Unexpected token (17:37)

> 17 | const SwitchWithProps = ({ children, ...restProps }) => (

@alangpierce
Copy link
Owner

@iki Take a look at webpack/webpack#5548 (comment) , that may have some pointers. I think there are unfortunately some node_modules issues where it's possible to be stuck on an old acorn even though webpack 4 should depend on a recent enough version that supports the syntax. The syntax works for me in webpack 4 with a fresh install, so maybe try reinstalling node_modules from scratch or regenerating your lockfile.

@iki
Copy link

iki commented Jun 7, 2018

@alangpierce thanks! updating acorn resolved that: webpack/webpack#5548 (comment)

@alangpierce
Copy link
Owner

Cool, glad to hear.

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

3 participants