Minification not working properly #17227
-
Bug reportWhen importing a library on a page (or in another file that is used on a page), the minification does not work correctly and bloats the js files. To ReproduceI added a very simple test.js to my pages folder that looks like this: import React from "react";
import mdx from "@mdx-js/mdx";
const TestPage = props => {
return <h1>This is a headline</h1>;
};
export default TestPage; and also added some lines to my next.config.js to make the build work: module.exports = {
webpack(config, { isServer }) {
if (!isServer) {
config.node = {
fs: "empty",
};
}
return config;
}; Expected behaviorThe imported mdx-Library is not used so I would expect it to be removed on minification. As you can see in the screenshot, there is a huge size dfference between the test-page with and without the import. ScreenshotsSystem information
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
MDX is probably not marked as side-effect free. This is not a Next.js bug so I'll convert it to a discussion. |
Beta Was this translation helpful? Give feedback.
MDX is probably not marked as side-effect free. This is not a Next.js bug so I'll convert it to a discussion.