Closed ghost closed 4 years ago
Can confirm same issue happening here after upgrading file-loader from v4.2.0 to v5.0.2.
Duplicate of https://github.com/smooth-code/svgr/issues/362
Why is this issue closed @evilebottnawi?
Checking yarn.lock does not show any information that it is using smooth-code/svgr#362.
As I can only change the version of file-loader
to resolve this problem, I think it should be handled here too.
@markusdanek do you read changelog? we switch on ES modules so some other non official loaders can buggy, we can't solve this on our side, look in you stack trace in error:
/node_modules/@svgr/webpack/lib?-svgo!./src/icons/Pay.svg
You can see what problem in @svgr/webpack
package
Yes I read the changelog and saw the breaking change with ESModule.
It still was not clear to me that this also affects other packages that file-loader
is using.
@markusdanek yes it can affect, potential buggy place https://github.com/smooth-code/svgr/blob/master/packages/webpack/src/index.js#L34
@markusdanek you can fix it using esModule: false
, but you build size will be increased because it is do impossible concatenated modules
Faced the same issue, resolved it by adding individual export entries in image directory like below.
/Icons
success.svg
error.svg
info.svg
It's been imported as direct svg file as ReactComponent
like below.
import { ReactComponent as PaymentAggregation } from './Icons/success.svg';
Step 1: Added index.js to Icons
directory.
/Icons
index.js
success.svg
error.svg
info.svg
Step 2: Exported as individual file in index.js
export { default as SuccessIcon } from './success.svg';
export { default as ErrorIcon } from './error.svg';
export { default as InfoIcon } from './info.svg';
Final Step 3: call them as component
import { SuccessIcon } from './Icons';
Expected Behavior
Load SVG icon in JSX.
Actual Behavior
Code
How Do We Reproduce?
After updating
file-loader
from v4.2.0 to v5.0.2 I am getting this error.