Skip to content

CommonJS model: forwardsOutside is skipped by the import reader and not memoized #35

Open

Description

@inth3shadows

Found in the PR #29 round-14 review. Two follow-ups on forwardsOutside, the cross-file check for "this file forwards its whole export into a file outside the model":

  1. The incremental import reader skips it. module-importers.ts calls collectCommonJsExportEvidence directly. For a.js: module.exports = require('./esm'), resolution uses the pre-model path, but reader.commonJs(a.js) returns true and reExports returns a synthetic wildcard. Sync reopening therefore follows a model the resolver does not use. No edge difference has been found yet; it only widens reopening.
  2. No memo. It reruns on every commonJsExportEvidence call (resolveModuleFile, readFile and a source compare per hop, up to 8 hops). resolveViaImport, matchReference and defaultModuleNamespace each call it again for the same file. Memoize per (context, file) and keep the record in a local in resolveViaImport.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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