This change contains an initial implementation of closure serialization built atop V8, rather than our own custom runtime. This requires that we use a Node.js dynamic C++ module, so that we can access the V8 APIs directly. No build magic is required beyond node-gyp. For the most part, this was straight forward, except for one part: we have to use internal V8 APIs. This is required for two reasons: 1) We need access to the function's lexical closure environment, so that we may look up closure variables. Although there is a tantalizingly-close v8::Object::CreationContext, its implementation intentionally pokes through closure contexts in order to recover the Function constructor context instead. That's not what we want. We want the raw, unadulterated Function::context. 2) We need to control the lexical lookups of free variables so that they can look past chained contexts, lexical contexts, withs, and eval-style context extensions. Simply runing a v8::Script, or simulating an eval, doesn't do the trick. Hence, we need to access the unexported v8::internal::Context::Lookup function. There is a third reason which is not yet implemented: free variable calculation. I could use Esprima, or do my own scanner for free variables, but I'd prefer to simply use the V8 parser so that we're using the same JavaScript parser across all components. That too is not part of the v8.h API, so we'll need to crack it open more. To be clear, these are still exported public APIs, in proper headers that are distributed with both Node and V8. They simply aren't part of the "stable" v8.h surface area. As a result, I do expect that maintaining this will be tricky, and I'd like to keep exploring how to do this without needing the internal dependency. For instance, although this works with node-gyp just fine, we will probably be brittle across versions of Node/V8, when the internal APIs might be changing. This will introduce unfortunate versioning headaches (all, hopefully and thankfully, caught at compile-time).
37 lines
1.6 KiB
JSON
37 lines
1.6 KiB
JSON
{
|
|
"name": "@pulumi/pulumi-fabric",
|
|
"version": "0.0.1",
|
|
"description": "Pulumi's Fabric Node.js SDK",
|
|
"repository": "https://github.com/pulumi/pulumi-fabric/sdk/nodejs",
|
|
"main": "bin/index.js",
|
|
"typings": "bin/index.d.ts",
|
|
"scripts": {
|
|
"clean": "rm -rf bin/ && rm -rf runtime/native/build",
|
|
"build": "npm run copyprotos && tsc && npm run binplace && npm run lint",
|
|
"lint": "tslint '*.ts' 'cmd/**/*.ts' 'asset/**/*.ts' 'runtime/**/*.ts' 'test/**/*.ts'",
|
|
"copyprotos": "cp -r ../proto/nodejs proto/",
|
|
"binplaceprotos": "cp -r proto/ bin/proto/",
|
|
"binplacenative": "mkdir -p bin/runtime/native/build/ && cp -r runtime/native/build/ bin/runtime/native/build/",
|
|
"binplacetestdata": "mkdir -p bin/tests/langhost/cases/ && find tests/langhost/cases/* -type d -exec cp -R {} bin/tests/langhost/cases/ \\;",
|
|
"binplace": "npm run binplaceprotos && npm run binplacenative && npm run binplacetestdata",
|
|
"test": "npm run cov && npm run covreport",
|
|
"cov": "istanbul cover --print none node_modules/.bin/_mocha -- --timeout 15000 'bin/tests/**/*.spec.js'",
|
|
"covreport": "istanbul report text-summary && istanbul report text"
|
|
},
|
|
"devDependencies": {
|
|
"@types/minimist": "^1.2.0",
|
|
"@types/mocha": "^2.2.42",
|
|
"@types/node": "^8.0.25",
|
|
"istanbul": "^0.4.5",
|
|
"mocha": "^3.5.0",
|
|
"tslint": "^5.6.0",
|
|
"typescript": "^2.1.4"
|
|
},
|
|
"dependencies": {
|
|
"google-protobuf": "^3.4.0",
|
|
"grpc": "^1.4.1",
|
|
"minimist": "^1.2.0",
|
|
"source-map-support": "^0.4.16"
|
|
}
|
|
}
|