chore: support node 10
This commit is contained in:
Vendored
+2
-1
@@ -13,5 +13,6 @@
|
||||
"lib/**/*": true,
|
||||
"**/node_modules": true,
|
||||
"**/bower_components": true
|
||||
}
|
||||
},
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib"
|
||||
}
|
||||
|
||||
Generated
+10778
-475
File diff suppressed because it is too large
Load Diff
+7
-5
@@ -43,8 +43,9 @@
|
||||
"mkdirp": "^0.5.1",
|
||||
"ora": "^2.0.0",
|
||||
"pify": "^3.0.0",
|
||||
"resolve-dependencies": "^1.1.4",
|
||||
"rimraf": "^2.6.2"
|
||||
"resolve-dependencies": "^1.2.0-next",
|
||||
"rimraf": "^2.6.2",
|
||||
"semver": "^5.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.1.2",
|
||||
@@ -52,13 +53,14 @@
|
||||
"@types/globby": "^6.1.0",
|
||||
"@types/minimist": "^1.2.0",
|
||||
"@types/mkdirp": "^0.5.2",
|
||||
"@types/mocha": "^2.2.48",
|
||||
"@types/ora": "^1.3.3",
|
||||
"@types/mocha": "^5.0.0",
|
||||
"@types/ora": "^1.3.4",
|
||||
"@types/pify": "3.0.1",
|
||||
"@types/rimraf": "2.0.2",
|
||||
"@types/semver": "^5.5.0",
|
||||
"chai": "^4.1.2",
|
||||
"execa": "^0.10.0",
|
||||
"mocha": "^5.0.4",
|
||||
"mocha": "^5.0.5",
|
||||
"prettier": "^1.11.1",
|
||||
"ts-node": "5.0.1",
|
||||
"tslint": "^5.9.1",
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
//add placeholder patches so methods can be monkeypatched after being dereferenced
|
||||
const __nexe_patches = ((process as any).nexe = { patches: {} }).patches as any
|
||||
|
||||
function __nexe_noop_patch(this: any, original: any, ...args: any[]) {
|
||||
return original.call(this, ...args)
|
||||
}
|
||||
|
||||
function __nexe_patch(obj: any, method: string, patch: any) {
|
||||
__nexe_patches[method] = patch
|
||||
const original = obj[method]
|
||||
if (!original) return
|
||||
__nexe_patches[method] = patch
|
||||
obj[method] = function(this: any, ...args: any[]) {
|
||||
return __nexe_patches[method].call(this, original, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
__nexe_patch((process as any).binding('fs'), 'internalModuleReadFile', __nexe_noop_patch)
|
||||
__nexe_patch((process as any).binding('fs'), 'internalModuleReadJSON', __nexe_noop_patch)
|
||||
__nexe_patch((process as any).binding('fs'), 'internalModuleStat', __nexe_noop_patch)
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
import { NexeCompiler } from '../compiler'
|
||||
import { readFileSync } from 'fs'
|
||||
import semver = require('semver')
|
||||
import { join } from 'path'
|
||||
import { wrap } from '../util'
|
||||
|
||||
export default async function main(compiler: NexeCompiler, next: () => Promise<void>) {
|
||||
const bootPath =
|
||||
(compiler.target.version.startsWith('4') ? 'src/' : 'lib/internal/bootstrap_') + 'node.js'
|
||||
const file = await compiler.readFileAsync(bootPath)
|
||||
const parts = file.contents.split('function(process) {')
|
||||
file.contents =
|
||||
parts[0] + `function(process) {` + '{{replace:lib/patches/bootstrap.js}}' + parts[1]
|
||||
let bootFile = 'lib/internal/bootstrap_node.js'
|
||||
const { version } = compiler.target
|
||||
|
||||
if (semver.satisfies(version, '4')) {
|
||||
bootFile = 'src/node.js'
|
||||
} else if (semver.gt(version, '9.10.1')) {
|
||||
bootFile = 'lib/internal/boostrap/node.js'
|
||||
}
|
||||
|
||||
const file = await compiler.readFileAsync(bootFile),
|
||||
matches = file.contents.match(/\(function.*/),
|
||||
functionHeader = matches && matches[0]
|
||||
|
||||
if (!functionHeader) {
|
||||
throw new Error('Failed to find bootstrap header in node version: v' + version)
|
||||
}
|
||||
|
||||
file.contents.replace(
|
||||
functionHeader,
|
||||
functionHeader + '\n' + '{{replace:lib/patches/bootstrap.js}}'
|
||||
)
|
||||
|
||||
await compiler.setFileContentsAsync(
|
||||
'lib/_third_party_main.js',
|
||||
|
||||
+5
-3
@@ -8,16 +8,18 @@ function makeRelative(cwd: string, path: string) {
|
||||
return './' + relative(cwd, path)
|
||||
}
|
||||
|
||||
let producer = async function(compiler: NexeCompiler) {
|
||||
let producer = async function(compiler: NexeCompiler): Promise<string> {
|
||||
const { cwd, input } = compiler.options
|
||||
const { files } = await resolveFiles(compiler.options.input, { cwd, expand: true })
|
||||
const { files, entries } = await resolveFiles(input, { cwd, expand: true })
|
||||
const mainFileContents = (entries[input].contents as string) || ''
|
||||
|
||||
Object.keys(files).forEach(filename => {
|
||||
const file = files[filename]!
|
||||
if (file && file.contents) {
|
||||
compiler.addResource(makeRelative(cwd, filename), Buffer.from(file.contents))
|
||||
}
|
||||
})
|
||||
return Promise.resolve('require(' + JSON.stringify(makeRelative(cwd, input)) + ')')
|
||||
return Promise.resolve(mainFileContents)
|
||||
}
|
||||
|
||||
export default async function bundle(compiler: NexeCompiler, next: any) {
|
||||
|
||||
Reference in New Issue
Block a user