-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 wrong babel usage #482
Comments
Well, looks like that Instead of that There are two questions from me
|
It takes into account the first .babelrc it sees, so in this case the one from |
async function resolve(filepath, filenames, root = path.parse(filepath).root) {
filepath = path.dirname(filepath);
// Don't traverse above the module root
if (filepath === root || path.basename(filepath) === 'node_modules') {
return null;
}
for (const filename of filenames) {
let file = path.join(filepath, filename);
let exists = existsCache.has(file)
? existsCache.get(file)
: await fs.exists(file);
if (exists) {
existsCache.set(file, true);
return file;
}
existsCache.set(file, false);
}
return resolve(filepath, filenames, root);
} Right first, but if there is no Still, the question is the same, why |
Yeah that's the point, if there is non in node_modules it goes up to project root but never past that so that makes sense. |
Where do you see any validation that the asset is inside of
The same for me, I don't know why do you guys transpile |
@nnnikolay there is no validation if it's in node_modules or not, this piece of code prevents traversing outside of the project though: // Don't traverse above the module root
if (filepath === root || path.basename(filepath) === 'node_modules') {
return null;
} |
@DeMoorJasper not only the project but also module/package folder as well. Sorry if I confused you with my explanation, let me try one more time. Parcel takes file by file to build the bundle. In the process, there are couple of stages async process() {
if (!this.generated) {
await this.loadIfNeeded();
await this.pretransform();
await this.getDependencies();
await this.transform();
this.generated = this.generate();
this.hash = this.generateHash();
}
return this.generated;
} Some of the assets are located inside |
Having a similar issue - is there a way to disable babel on node_modules?
|
@azz This is exactly the issue what I'm talking about here, and yep package Here is one more example
It's enough to check that the path of the current asset ( I've tried to do something like that async function shouldTransform(asset) {
if (asset.name.indexOf('node_modules') !== -1) {
return false;
}
if (asset.isES6Module) {
return true;
}
if (asset.ast) {
return !!asset.babelConfig;
}
if (asset.package && asset.package.babel) {
return true;
}
let babelrc = await config.resolve(asset.name, ['.babelrc', '.babelrc.js']);
return !!babelrc;
} but it does not work somehow :( |
Same in #515 |
I've also encountered this problem. Im trying to create some starter app with react and material-ui. With the latest version parcel is working great. But when I want to use material-ui@next the problem with babelrc shows up. There are multiple packages in nodemodules that contains Babelrc file which parcel tries to ctranspile and this is causing crash preventing my app to run. After deleting all Babelrc files from modules app successfully starts up bit then there are some problem with importing components from material-ui :( |
Having the same issue. It seems many dependencies -- whether they should or not -- package .babelrc with their npm package. I agree with others on this thread that parcel should probably not build or pay any attention to dependencies' build configuration. Moreover, speaking as someone trying to use parcel on a new project, this issue is common enough that it makes for a pretty poor first-time experience if you hit it. Regardless of whether parcel or the underlying libraries are at fault, parcel is the only build system that exposes this problem. It would be a welcome change to have this fixed. @DeMoorJasper Is there some core parcel functionality that relies on this behavior? Also, I have a .babelrc in my project root and parcel still picks up dependency .babelrc files. FWIW, I ran into this problem here: react-dropzone/attr-accept#16. |
For anyone else who stumbles on this issue, the main discussion thread for the underlying issue is #13. This issue should likely be closed. |
In v1.6.0, we no longer transpile node_modules by default. Closing. |
@devongovett This is a controversial move. I know that Is there a way to reactivate transpilation/babelification of node_modules? [edit] just found your contribution #1101 which suits my needs. Will try now. |
I don't know is that a bug report or my mistake, but whole day today I'm struggling and get different behavior from time to time.
This is my .babelrc
and this is the message what I see
that happens when I use
react-dropzone
package. Looks like that parcel/babel transpile node_modules as well?here is my package.json
as soon as I don't use that package everything is ok.
The text was updated successfully, but these errors were encountered: