I am working on a react app that uses skpm and react-sketchapp. I am importing a node module that uses ES.Next syntax, so I need to use babel to parse that modules directory (node_modules/react-native-calendars ).
skpm acts as the packager for the app, and uses webpack with babel-loader. The webpack config file in skpm is set to exclude the node_modules directory. As such, I am getting a build error in the node_modules/react-native-calendars directory.
I think I can provide a webpack.config.js file in the root of my project that overrides the node_modules exlcude for node_modules/react-native-calendars.
In modules / rules I originally had:
include: (/node_modules\/react-native-calendars/), exclude: (/node_modules/), but I think I need something like:
exclude: new RegExp (/node_modules\/(?!(react-native-calendars))/), Here is the entire webpack.config.js:
module.exports = { module: { rules: [ { test: /\.jsx?$/, exclude: new RegExp (/node_modules\/(?!(react-native-calendars))/), use: { loader: 'babel-loader', options: { presets: ['react', 'es2015', 'stage-0'], plugins: ['transform-runtime', 'transform-class-properties'] } } } ] } }; And here is a link to the repo (only two short files in /src and a webpack config) : https://github.com/pcooney10/rn-calendar.
EDIT
I have changed the test from /\.jsx$/ to /\.jsx?$/, which is a step in the right direction, but now it seems that none of the imports in /node_modules/react-native-calendars are working. I am getting pages of logs that say Module not found: Error: Can't resolve 'SomeModule' and Field 'browser' doesn't contain a valid alias configuration.
EDIT 2: Do I need some sort of path.resolve(__dirname,..) statement?
testis explicitly for.jsxfiles, but you say you want to process.js. Is that your issue?.jsxinstead of.js. When I switch it to.js, I get a whole slew of errors that say my modules can't be found..jsor.jsx?/\.jsx?$/would cover both. I don't really think there is enough info in the question to answer this.