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

problem when bundling with webpack #13

Open
sibelius opened this issue Jan 9, 2021 · 3 comments
Open

problem when bundling with webpack #13

sibelius opened this issue Jan 9, 2021 · 3 comments

Comments

@sibelius
Copy link

sibelius commented Jan 9, 2021

requiring babel-register is causing trouble when bundling this package using webpack for lambdas: https://github.com/arthanzel/evaluatex/blob/master/index.js#L8

Module not found: Error: Can't resolve 'babel-register' in 'app/node_modules/evaluatex'

Module not found: Error: Can't resolve './src/evaluatex' in 'app/node_modules/evaluatex'

can we only keep the transpiled code? and avoid transpiling on the fly?

@arthanzel
Copy link
Owner

Could you post an example of a project where it's failing? Admittedly, it's an ancient loader but doing npm install evaluatex should be downloading only transpiled code, not the sources. Requiring babel-register is a development aid and it shouldn't normally be called.

@sibelius
Copy link
Author

I've made a tiny example here https://github.com/sibelius/evaluatex-webpack

yarn start works well
yarn prod will break

@arthanzel
Copy link
Owner

arthanzel commented Jan 11, 2021

I suspect that Webpack is optimistically trying to resolve babel-loader by statically analyzing the loader in evaluatex/index.js. With this change, it appears to compile:

- import evaluatex from 'evaluatex';
+ import evaluatex from 'evaluatex/dist/evaluatex';

A lot has changed in transpiling/bundling since the original Evaluatex was written and the way it is loaded is not the way to do things anymore. While theoretically I might be able to remove the loader entirely and make package.json:main point to dist/evaluatex.js unconditionally, I don't want to do that until I've written some tests that ensure the library is compiled well for server, browser, and bundlers. I hope that this is an acceptable workaround until then.

I'll keep this issue open for now.

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

No branches or pull requests

2 participants