Skip to content

Dynamic requires causes webpack to include test files in bundle #7

@davej

Description

@davej

react-xterm contains dynamic requires which causes Webpack to be overly aggressive when bundling and include all the addons and corresponding tests:

this.props.addons.forEach(s => {
  const addon = require(`xterm/dist/addons/${s}/${s}`);
  Terminal.applyAddon(addon);
});

Causing the following error:

* chai in ./node_modules/xterm/dist/addons/attach/attach.test.js, ./node_modules/xterm/dist/addons/fit/fit.test.js and 4 others
* express in ./node_modules/xterm/dist/addons/zmodem/demo/app.js
* express-ws in ./node_modules/xterm/dist/addons/zmodem/demo/app.js
Caused by this dynamic require which causes webpack to bundle all the addons and their tests:

Perhaps the signature of this.props.addons can be an array of the addon modules directly, rather than an array of strings which are converted into dynamic imports?

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