Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Sep 1, 2022
1 parent da282e7 commit 5ef6bc1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/data-context/src/data/ProjectConfigIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 5ef6bc1

Please sign in to comment.