Skip to content

Commit 8539121

Browse files
edusperoniNathanWalker
authored andcommitted
docs: record the no-source-text-modules decision; js2c rejects non-.js inputs
Builtins stay classic function bodies on both runtimes; cross-builtin sharing, if ever needed, starts with generation-time bundling. The js2c guard turns an accidental .mjs into a build error pointing at the spec.
1 parent 5b93d14 commit 8539121

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

docs/ns-builtin-modules.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ provide it.
123123
the registry distinguishes public modules from internal builtins, and only
124124
public ones resolve (Node's `canBeRequiredByUsers` split).
125125

126+
## Source-text modules: deliberately not supported
127+
128+
Builtins are classic function bodies, not ES modules, on both runtimes. If
129+
cross-builtin code sharing is ever needed, the first answer is bundling at
130+
generation time (author as ESM, emit function bodies); runtime source-text
131+
builtin modules (Node's `kSourceTextModule`) are justified only by a concrete
132+
need for live module semantics (TLA, live bindings, cyclic imports), which no
133+
current or planned builtin has. Revisit here before building either.
134+
126135
## iOS implementation notes (non-normative)
127136

128137
Builtin modules are function-body builtins (`NativeScript/runtime/js/`,

tools/js2c.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ for (const file of inputs) {
7777
console.error(`error: no such file: ${file}`);
7878
process.exit(1);
7979
}
80+
if (!file.endsWith('.js')) {
81+
console.error(`error: builtins must be .js function bodies, got: ${file}`);
82+
console.error('(.mjs/source-text modules are deliberately unsupported — see docs/ns-builtin-modules.md)');
83+
process.exit(1);
84+
}
8085
const stem = basename(file).replace(/\.js$/, '');
8186
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(stem)) {
8287
console.error(`error: file name must be kebab-case .js: ${file}`);

0 commit comments

Comments
 (0)