boopathi/react-svg-loader

Webpack loader no longer working in non-root webpack@3.x config

kylemh opened this issue ยท 3 comments

Hello ๐Ÿ‘‹ Love y'alls work!

Basically, I've got a very-up-to-date Next.js app, with a not-so-up-to-date Storybook app alongside it.

Next uses webpack@4.x / babel@7.x and Storybook is using webpack@3.x / babel@6.x, so I feel like the issue lies here, but it didn't seem like dependencies changed too drastically between 2 & 3 so ๐Ÿค”

The loader works without error in the Next app, but is failing when Storybook builds (both locally [dev server] and statically). The call-stack itself is pretty strange, as it appears as if the loader is working.

The error call-stack

ERROR in ./static/images/icons/FontAwesome/external-link-square-alt-solid.svg
Module parse failed: Unexpected token (6:2)
You may need an appropriate loader to handle this file type.
| export default (({
|   styles = {},
|   ...props
| }) => React.createElement("svg", _extends({
|   xmlns: "http://www.w3.org/2000/svg",
 @ ./components/OutboundLink/OutboundLink.js 16:57-140
 @ ./components/OutboundLink/__stories__/OutboundLink.stories.js
 @ ./components stories\.js$
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js ./node_modules/webpack-hot-middleware/client.js?reload=true ./.storybook/config.js

The repo / pull request

https://github.com/OperationCode/front-end/pull/470/files

The failure in CI

https://app.netlify.com/sites/operation-code-storybook/deploys/5cd13de405e7ec0009af2a33

It says module parse failed. I'm not sure why. I'm not sure which version of webpack started understanding es6 modules. Maybe that is the issue?

To be clear, this error showed up on @3.0.0 (and patch 1 and patch 2) but didn't show up previously.

Webpack 3 supports es6 modules natively.
https://webpack-v3.jsx.app/concepts/modules/#what-is-a-webpack-module

One idea I have is about .babelrc path resolution. I know you ignore .babelrc, but I have a nested .babelrc that extends a root-level one.

I'm hoping that the issue is somehow related to some other issue you've already resolved, and await a new release.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.