-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
REST (React): "msw" is included in the production bundle #10
Comments
I saw Kent run into this on stream too, but possibly for different reasons. The reason I ran into it was that I assigned 👍🏻 msw not in production bundle:
👎🏻 msw in production bundle:
(edit: note the example works just fine unmodified, so that was an invalid report) |
if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development') {
const { worker } = require('./mocks')
worker.start()
} This allows the bundler to eliminate the dead code paths, since it will be transformed to: if (false || false) { // Will never be true
const { worker } = require('./mocks')
worker.start()
} If the const isDevOrTest = false || false
if (isDevOrTest) { // Won't know the value `isDevOrTest` without running the code
const { worker } = require('./mocks')
worker.start()
} |
@thebuilder There we go, that sounds familiar. Thanks for the explanation! |
We need to add an automated test that asserts the |
Hey, any update on this? if it's not, can I pick this up? |
One of the users has reported that
msw
package is included in the production bundle of therest-react
example.Expected behavior
msw
must not be included in the production bundle.The text was updated successfully, but these errors were encountered: