Coder Social home page Coder Social logo

Improve Bundle Chunking about react-md-editor HOT 18 CLOSED

uiwjs avatar uiwjs commented on May 24, 2024 4
Improve Bundle Chunking

from react-md-editor.

Comments (18)

jaywcjlove avatar jaywcjlove commented on May 24, 2024 1

@kyeotic This requires writing a webpack plugin. This needs to be studied.

from react-md-editor.

kyeotic avatar kyeotic commented on May 24, 2024

I might be reading this incorrectly, but it looks like you hardcode the loading of all languages from prism. It would be nice to be able to pair this down, perhaps by using the prism webpack plugin in the client app and defining the languages as props.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@kyeotic These small JS files are loaded when used, and do not affect the size of the packaged JS.

My application scenario cannot determine which languages ​​to load.

from react-md-editor.

kyeotic avatar kyeotic commented on May 24, 2024

@jaywcjlove Yes, but the bundles are still present in the deployment, and they still add considerable noise to the build and source-map-explorer report. It would be nice if we could whitelist languages so that applications that did know which languages it supported could keep the rest from being bundled. This would be valuable even if the default was to bundle them all.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@kyeotic We need a plugin like monaco-editor-webpack-plugin

from react-md-editor.

kyeotic avatar kyeotic commented on May 24, 2024

I'm actually having a lot of trouble getting the prism webpack plugin to do anything. I tried forking this repo and trimming down the languages, then built with the prism plugin on the lib. I even added the plugin to the app that installed the editor, so that it was running in both places. I get 370+ bundles, which is smaller but not by half as many languages as I removed.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@kyeotic thx! this good idea. I will deal with it when I have time. @uiwjs/react-markdown-preview

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

Add Webpack configuration

https://github.com/uiwjs/react-baidu-map/blob/bff63bb0d175487203e2375380f3a76e860d0552/.kktrc.ts#L112-L117

from react-md-editor.

ppascualv avatar ppascualv commented on May 24, 2024

is there any possible solution without ejecting create-react-app?

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@ppascualv https://github.com/kktjs/kkt Override create-react-app webpack configs without ejecting

from react-md-editor.

ppascualv avatar ppascualv commented on May 24, 2024

Is there any solution for this issue or any workaround without ejecting the app? I was taking a look at your library but I'm not sure how can it solve the issue.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@ppascualv Add webpack config.

https://github.com/uiwjs/react-baidu-map/blob/74459dea893bc696819ae94bd900e01398ee9d1d/.kktrc.ts#L53-L166

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@ppascualv Dynamic import is used. Unable to split chunks it.

https://v4.webpack.js.org/plugins/split-chunks-plugin/#split-chunks-example-1

This configuration can enlarge your initial bundles, it is recommended to use dynamic imports when a module is not immediately needed.

from react-md-editor.

guoseven avatar guoseven commented on May 24, 2024

it's not work

webpack.config.js

 optimization: {

      // Automatically split vendor and commons
      // https://twitter.com/wSokra/status/969633336732905474
      // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
      splitChunks: {
        // chunks: 'all',
        // name: false,
        cacheGroups: {
          markdown_editor: {
            test: /[\\/]node_modules[\\/]@uiw[\\/]/,
            name: 'vendors-markdown',
            chunks: 'all',
          }
        }
      },
}

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@guoseven

prismjs: {
test: /[\\/]node_modules[\\/](prismjs)[\\/]/,
name: 'prismjs-vendor',
chunks: 'async',
},

from react-md-editor.

guoseven avatar guoseven commented on May 24, 2024

how to use it

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

@guoseven Modify webpack configuration. https://webpack.js.org/configuration/optimization/#optimizationsplitchunks

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 24, 2024

from react-md-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.