Skip to content
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

Allow babelConfig to be extended by user (or support compileLibs everywhere) #667

Open
s3ththompson opened this issue Sep 22, 2020 · 1 comment

Comments

@s3ththompson
Copy link

Is your feature request related to a problem? Please describe.
I can't build a component that imports an untranspiled ES module from a dependency. Three notoriously ships its examples (including OrbitControls, etc.) as untranspiled ESM. It looks like the undocumented compileLibs option is respected in src/pipeline/bundle-js but not in src/node-config.

Describe the solution you'd like
Ideally, idyll would allow extending the default babelConfig (perhaps similarly to how Next.js extends webpack config). This would allow userland solutions to my issue (transpiling an ES module from a dependency) but also other customization that might otherwise require adding and supporting additional flags.

Describe alternatives you've considered
Even if the compileLibs option was extended to turn on node_modules transpilation everywhere, the solution would be inefficient as transpiling all dependencies is expensive. In my case, it is only one dependency (three) which requires transpilation.

Additional context
I also tried to submit a simple PR to make src/node-config respect compileLibs by having babel-register compile node_modules, but couldn't get the approach to work as idyll has other dependencies in node_modules that break when run through babel-register.

@s3ththompson
Copy link
Author

FWIW, I needed to make this change to src/node-config to solve my problem:

require('babel-register')({
  presets: ['env', 'stage-2', 'react'],
   babelrc: false,
-  only: isWindows ? undefined : new RegExp(`(${transformFolders.join('|')})`)
+  ignore: [/node_modules\/(?!three)/],
});

It looks like the problem is made a bit more difficult by the fact that there are two layers of babel transformation happening? Does babel-register not respect other babelConfig?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants