You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,7 @@ Behavior notes (defaults in parentheses)
133
133
- `requireSource` (`builtin`): whether `require` comes from Node or `createRequire`.
134
134
- `cjsDefault` (`auto`): bundler-style default interop vs direct `module.exports`.
135
135
- `out`/`inPlace`: write the transformed code to a file; otherwise the function returns the transformed string only.
136
+
- CommonJS → ESM lowering will throw on `with` statements and unshadowed `eval` calls to avoid unsound rewrites.
136
137
137
138
See [docs/esm-to-cjs.md](docs/esm-to-cjs.md) for deeper notes on live bindings, interop helpers, top-level await behavior, and `import.meta.main` handling. For CommonJS to ESM lowering details, read [docs/cjs-to-esm.md](docs/cjs-to-esm.md).
138
139
@@ -141,3 +142,4 @@ See [docs/esm-to-cjs.md](docs/esm-to-cjs.md) for deeper notes on live bindings,
141
142
- Remove `@knighted/specifier` and avoid double parsing.
142
143
- Emit source maps and clearer diagnostics for transform choices.
143
144
- Broaden fixtures covering live-binding and top-level await edge cases across Node versions.
145
+
- Benchmark scope analysis choices: compare `periscopic`, `scope-analyzer`, and `eslint-scope` on fixtures and pick the final adapter.
This library tracks module-scope identifiers so CJS↔ESM lowering can avoid collisions and emit correct exports/imports. We model only hoisting behaviors that affect module-scope resolution and skip cases that either error at runtime or are handled by the module loader.
6
+
7
+
## What we treat as hoisted
8
+
9
+
-`function` declarations at module scope: reads before the declaration are counted.
10
+
-`var` declarations at module scope: reads before the declaration are counted (value is `undefined`).
11
+
12
+
## What we do not hoist
13
+
14
+
-`let` / `const` / `class`: reads in the temporal dead zone are ignored for hoist accounting (they are runtime errors). See fixtures/tests under `test/fixtures/identifiers/hoisting/tdz.js`.
15
+
-`import` bindings: import hoisting is handled by the module system; we exclude imports from module-scope hoist tracking. See `test/fixtures/identifiers/hoisting/importHoist.js`.
16
+
- Function declarations inside blocks (strict mode): they stay block-scoped and are not treated as module-scope hoists. See `test/fixtures/identifiers/hoisting/functionInBlock.js`.
17
+
18
+
## Why this scope
19
+
20
+
- Our goal is collision-free lowering, not simulating all JS runtime hoisting/TDZ behavior.
21
+
- Excluding TDZ and import hoists keeps the identifier table focused on cases that meaningfully affect CJS↔ESM transforms.
0 commit comments