From 1023b72513cfbf4b36ccfa0ce4c19f719e2aa994 Mon Sep 17 00:00:00 2001 From: calebboyd Date: Wed, 12 Jun 2019 16:03:31 -0500 Subject: [PATCH] fix: update patches for node 12 bootstrapping --- package-lock.json | 2 +- package.json | 2 +- src/patches/third-party-main.ts | 26 +++++++++++++++++++++----- src/steps/bundle.ts | 9 +++++++-- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9fa29a8..c010a78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nexe", - "version": "3.2.2", + "version": "3.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 297d779..e62ac85 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nexe", "description": "Create a single executable out of your Node.js application", "license": "MIT", - "version": "3.2.2", + "version": "3.3.0", "contributors": [ "Craig Condon (http://crcn.io)", "Jared Allard ", diff --git a/src/patches/third-party-main.ts b/src/patches/third-party-main.ts index 36bb927..282e731 100644 --- a/src/patches/third-party-main.ts +++ b/src/patches/third-party-main.ts @@ -1,6 +1,6 @@ import { NexeCompiler } from '../compiler' import { parse } from 'cherow' -import { semverGt } from '../util' +import { wrap, semverGt } from '../util' function walkSome(node: any, visit: Function) { if (!node || typeof node.type !== 'string' || node._visited) { @@ -29,6 +29,8 @@ export default async function main(compiler: NexeCompiler, next: () => Promise Promise StartMainThreadExecution(Environment* env) {', + 'MaybeLocal StartMainThreadExecution(Environment* env) {\n' + + ' return StartExecution(env, "internal/main/run_main_module");\n' + ) + } else { + await compiler.setFileContentsAsync( + 'lib/_third_party_main.js', + '{{replace:lib/patches/boot-nexe.js}}' + ) + } return next() } diff --git a/src/steps/bundle.ts b/src/steps/bundle.ts index d2c5139..ff02c1a 100644 --- a/src/steps/bundle.ts +++ b/src/steps/bundle.ts @@ -2,7 +2,7 @@ import { NexeCompiler, NexeError } from '../compiler' import { resolve, relative } from 'path' import { each } from '@calebboyd/semaphore' import resolveFiles, { resolveFileNameSync } from 'resolve-dependencies' -import { dequote, STDIN_FLAG } from '../util' +import { dequote, STDIN_FLAG, semverGt } from '../util' import { Readable } from 'stream' function getStdIn(stdin: Readable): Promise { @@ -29,7 +29,12 @@ export default async function bundle(compiler: NexeCompiler, next: any) { const { bundle, cwd, input: inputPath } = compiler.options let input = inputPath compiler.entrypoint = './' + relative(cwd, input) - compiler.startup = ';require("module").runMain();' + + if (semverGt(compiler.target.version, '11.99')) { + compiler.startup = '' + } else { + compiler.startup = ';require("module").runMain();' + } if (!bundle) { await compiler.addResource(resolve(cwd, input))