Closed kraizman closed 7 years ago
Hello!
Thanks for letting me know!
An interesting coincidence, I have just pushed the major update of react-xmasonry to version 2.0.0
. Please, check it out.
What you do by using
exclude: /node_modules/,
option is telling WebPack to not to transpile any code inside node_modules
directory, obviously. Let me explain what happens here.
The node_modules/react-xmasonry
module has 2 entry points (check its package.json):
src/index.js
for ES modules-enabled bundlers;dist/index.js
for anything else.Because of you using WebPack, which picks package.module property up, it tries to load src/index.js
, which is ES6 react code, and you need to use an appropriate loader for it, which you have disabled by exclude
.
So you have 2 options here:
exclude: /node_modules/,
line from your WebPack config file.import { XMasonry, XBlock } from "react-xmasonry/dist/index.js"
, which will import UMD already-transpiled module.The preferred option is always the first one, because:
Hope this helps, let me know!
Thanks for quick response. I will definitely new version. Also, I discovered better webpack configuration so babel will not try to transpile all dependencies in node_modules directory. I divided resolve configurations to 2:
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
'react-hot-loader',
'babel-loader?presets[]=react,presets[]=es2015,presets[]=stage-0'
]
},
{
test: /\.jsx$/,
loaders: [
'react-hot-loader',
'babel-loader?presets[]=react,presets[]=es2015,presets[]=stage-0'
]
},
Thanks for help and grate library. Looks very promissing.
Thank you!
Your solution definitely make sense in case of react-xmasonry
. But in general, I think some ES6-module packages may also have files using ES6-7 features with .js
extension, be careful here.
Hi, I try to add your library to my project but got error in building
In my webapck config i resolve jsx like
Do you have any idea why i am getting this error and how to fix it?