Description
Consider a simple project with a single source file main.ts
, containing
console.log("hello world!");
Compiling this project with --entryPoint main
and then running with node bin/bundle.js
gives
Error: module "main" not found.
This module can be compiled and run, producing the expected result, if the --entryPoint
argument is removed from the compile step. However, if I add a second source file, other.ts
, containing
export default "Hello world!";
and modify main.ts
to import greeting from './other'
and log it, then compiling with an explicit --entryPoint main
compiles and runs as expected. The difference between the two is clear from the generated JavaScript: the latter produces a call to define("main", ...
whereas in the former the log statement appears directly in the top-level IIFE.
It is not clear to me what determines whether code ends up directly in the IIFE vs in a call to define
, but this behavior was certainly unexpected to me and feels like a bug.