diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index a2125ae9844f..3a96e89f9912 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -271,7 +271,9 @@ export class ProjectConfigIpc extends EventEmitter { // ts-node for CommonJS // ts-node/esm for ESM if (hasTypeScriptInstalled(this.projectRoot)) { + debug('found typescript in %s', this.projectRoot) if (isProjectUsingESModules) { + debug(`using --experimental-specifier-resolution=node with --loader ${tsNodeEsm}`) // Use the ts-node/esm loader so they can use TypeScript with `"type": "module". // The loader API is experimental and will change. // The same can be said for the other alternative, esbuild, so this is the @@ -294,6 +296,8 @@ export class ProjectConfigIpc extends EventEmitter { // so we need to load and evaluate the hook first using the `--require` module API. const tsNodeLoader = `--require "${tsNode}"` + debug(`using cjs with --require ${tsNode}`) + if (childOptions.env.NODE_OPTIONS) { childOptions.env.NODE_OPTIONS += ` ${tsNodeLoader}` } else { @@ -303,6 +307,7 @@ export class ProjectConfigIpc extends EventEmitter { } else { // Just use Node's built-in ESM support. // TODO: Consider using userland `esbuild` with Node's --loader API to handle ESM. + debug(`no typescript found, just use regular Node.js`) } return fork(CHILD_PROCESS_FILE_PATH, configProcessArgs, childOptions)