Skip to content

Code splitting and building #101

@edemaine

Description

@edemaine

Currently, the compiled svgtiler.js file (158kB, 42kB gzipped) has a lot of code that is command-line-specific, and doesn't make sense for a web-only build. Also, we don't include any dependencies in a web build.

  • Separate source files into base svgtiler.coffee and nodetiler.coffee which requires svgtiler.coffee.
    • Ideally all simulated-on-web imports like path would only be needed in latter, so we could remove these simulations.
    • For Node, package.json's bin and main point to nodetiler.js
  • Plausibly split into separate files for each class, for easier code navigation.
  • Web-specific builds in dist built by rollup or Parcel or webpack
    • Full build including CoffeeScript, @babel/standalone for JSX, Stylus, csv/xls parsers, etc.
    • Intermediate builds with different subsets?
    • May need a bare build seperate from svgtiler.js (in case of further splitting, and to fully avoid require/import).
  • Alternatively, can we use code splitting features to automatically load dependencies as needed? This is challenging given how the code is currently written synchronously.
  • Alternatively, can we just rely on dependencies being globally attached to window? Ideally each class could specify its dependencies, and expect the user to (lazy) load them before instantiating that class.
  • Provide tree-shakable ESM source (I guess in lib). nodetiler.js won't be tree-shakable because of svgtiler megafunction (or can Parcel figure it out?), but that's Node anyway; svgtiler.js (for web) should be possible.
  • svgink could similarly split off its CLI code so it doesn't up in any build of svgtiler (as we never need it).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions