Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Issues
  • #633
Closed
Open
Issue created Jan 22, 2017 by Tim Disney@disnetContributor

Remaining module work

Sweet's module support is getting better, especially with recursive for syntax support #624. But we've still got a ways to go.

The major remaining areas of work are:

  • import/export for arbitrary phase
  • CommonJS support
  • implicit runtime imports

Importing for an arbitrary phase is relatively straightforward, just add support for syntax like import { x } from 'mod' for phase 2 and wire the phase number appropriately.

CommonJS will require a bit of design thought. Should we instantiate separately for each phase? Probably, but if not we could just reuse require in the NodeLoader. How should we detect CommonJS vs ES2015? Node core still hasn't decided this but hopefully we can just follow their cowpath.

Implicit runtime imports allow runtime module dependencies to be tracked through macro expansion. To do this right I think we basically have to turn Sweet into a ES2015 module bundler:

// a.js
// ========================
import f from 'f';

export syntax m = ctx => {
  return #`f()`;
}

// main.js
// ========================
import { m } from 'a.js'

m;

// should expand into:
// ========================
import f from 'f';
f();

// or even better with full bundling:
// ========================
let f = // implementation of f
f();

The design of this is cross-cutting with how we decide to handle CommonJS.

Since hygiene gives us so much scope information I think we'd get rollup-style tree-shaking optimizations "for free".

Assignee
Assign to
Time tracking