Skip to content

problem when bundling with webpack #13

Open

Description

@sibelius

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?

Activity

  1. arthanzel commented on Jan 9, 2021

    @arthanzel
    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.

  2. sibelius commented on Jan 11, 2021

    @sibelius
    Author

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

    yarn start works well
    yarn prod will break

  3. arthanzel commented on Jan 11, 2021

    @arthanzel
    Owner

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions