Skip to content

Commit

Permalink
fix: use ts-node inside the egg-bin deps (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Sep 16, 2023
1 parent 03e9f02 commit f13df56
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/middleware/global_options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { debuglog } from 'node:util';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import {
Inject, ApplicationLifecycle, LifecycleHook, LifecycleHookUnit,
Program, CommandContext,
Expand Down Expand Up @@ -104,7 +105,14 @@ export default class implements ApplicationLifecycle {
}
if (pkg.type === 'module') {
// use ts-node/esm loader on esm
addNodeOptionsToEnv('--loader ts-node/esm', ctx.env);
let esmLoader = require.resolve('ts-node/esm');
if (process.platform === 'win32') {
// ES Module loading with abolute path fails on windows
// https://github.com/nodejs/node/issues/31710#issuecomment-583916239
// https://nodejs.org/api/url.html#url_url_pathtofileurl_path
esmLoader = pathToFileURL(esmLoader).href;
}
addNodeOptionsToEnv(`--loader ${esmLoader}`, ctx.env);
}

debug('set NODE_OPTIONS: %o', ctx.env.NODE_OPTIONS);
Expand Down

1 comment on commit f13df56

@vercel
Copy link

@vercel vercel bot commented on f13df56 Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

egg-bin – ./

egg-bin.vercel.app
egg-bin-no-veronica.vercel.app
egg-bin-git-master-no-veronica.vercel.app

Please sign in to comment.