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

Webpack bundle size increases dramatically with rewire #228

Open
toanqc opened this issue Nov 14, 2019 · 1 comment
Open

Webpack bundle size increases dramatically with rewire #228

toanqc opened this issue Nov 14, 2019 · 1 comment

Comments

@toanqc
Copy link

toanqc commented Nov 14, 2019

I installed babel-plugin-rewire modules to my project.
npm install babel-plugin-rewire
And config the .babelrc plugin with
"plugins": ["transform-object-rest-spread", "rewire"]

Now when I build the project, I see that the webpack bundle is increased dramatically (almost 2 MB)
From
app.js 6.49 MB 0 [emitted] [big] app
To
app.js 8.33 MB 0 [emitted] [big] app

Is this expected? Is there a way that I can use rewire so that I can test my private unit test and remove it from the webpack bundle?

@Mesqalito
Copy link

You should probably use .babelrc.js and provide conditional config:

module.exports = api => ({
    // ...
    plugins: [
        ...api.env('test') ? ['babel-plugin-rewire'] : []
    ]
});

This way rewire should only run when you run tests. Also check if env variable is set to test if your test runner doesn't do it for you already.

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