Skip to content

Explore using dynamic imports and react-loadable to chunk the js #52

@hellochar

Description

@hellochar

In test-react-loadable, we attempted to use dynamic imports along with react-loadable to split our web-app based on React component/feature. This would give us several benefits:

  • reduce load time of main page
  • allow us to create a separate bundle for installation stuff (e.g. opencv, all the wip/ stuff)
  • allow us to unify more disparate parts together, since we worry less about bundle bloat
  • allow us to only download the assets and js files we need to for each specific sketch
  • allow us to write "global"-like code in sketches that don't actually run/use resources until that sketch is loaded (although this seems like a code smell)

Problems
To do this, we needed to use "module": "esnext" in tsconfig.json for typescript to properly emit real import() statements that webpack could then parse. But this breaks threejs's example extensions, since they all rely on a global THREE object. We can kind of work around this by using webpack's import-loader/export-loader but it needed more work.

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