-
Notifications
You must be signed in to change notification settings - Fork 213
Babel not working for library code #1046
Comments
Hi! The neutrino/packages/web/index.js Lines 89 to 94 in f741f9e
There's probably something else going wrong - could you post a complete testcase repo? |
I think the problem is that babel excludes compile: {
exclude: [/node_modules(?!\/react-native-elements)/]
} Project setup: After adding |
There are a few parts to this:
// .neutrinorc.js
const { join } = require('path');
module.exports = {
use: [
['@neutrinojs/react', {
// Any preset options here.
}],
// Use the Neutrino API to make changes that are not possible via the preset's options.
(neutrino) => {
// Also Babel transpile node_modules (in addition to the project source/tests).
neutrino.config.module
.rule('compile')
.include.add(join(__dirname, 'node_modules'));
},
],
};
|
Thanks for your explanation.
So I tried with, which results in the initial error: compile: {
include: [ join(__dirname, 'node_modules', 'react-native-elements') ]
}
|
Ah sorry I misread the preset here: neutrino/packages/web/index.js Lines 111 to 118 in f741f9e
Adding the |
@eliperelman, I can think of a few things we can do to help with this:
|
My preference is definitely (1), since we have spent a lot of time reducing top-level options that just duplicate other functionality. |
I've filed #1100 for adding this to the docs. |
@edmorley @eliperelman should we add a |
@piu130 feel free to open a PR and we can discuss it there. |
Trying to auto-detect whether a project is using packages that don't compile down to ES5 by looking around |
Bug?
What version of Neutrino are you using?
"neutrino": "^8.3.0"
Are you trying to use any presets? If so, which ones, and what versions?
"@neutrinojs/react": "^8.3.0"
Are you using the Yarn client or the npm client? What version?
"yarn": "1.9.4"
What version of Node.js are you using?
"node": "10.8.0"
What did you do?
I created a project with
npx @neutrinojs/create-project test
, and added a library (react-native-elements
) that uses object spread syntax.What did you expect to happen?
It should compile and display the website.
What actually happened, contrary to your expectations?
This error (and many others):
How do I configure babel to support library code?
The text was updated successfully, but these errors were encountered: