I'm trying to get pkg working with esm and I've hit an issue which I can't seem to trackdown the source.
TypeError: this._checkModeProperty is not a function
at Object.Stats.isFile (internal/fs/utils.js:183:15)
at Object.<anonymous> (/snapshot/express-es6/index.js:4:1)
at Module._compile (pkg/prelude/bootstrap.js:1254:22)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:711:10)
at Module.load (internal/modules/cjs/loader.js:610:32)
To reproduce:
git clone https://github.com/OmgImAlexis/pkg
cd pkg/examples/express-es6
npm -g pkg
pkg .
./express-example
I'm assuming it's got something todo with how they change require.
https://github.com/zeit/pkg/blob/4bdbd6a95f64479a3e651a155fa0d72f1f38c489/prelude/bootstrap.js#L1145-L1313
Any updates?
I also came across this need, and I am doing some experiments to try to get esm work with pkg. Here is what I've found:
pkg is using vm.Script to compile source code into v8 byte code. For that to happen, I will need to get the "transformed" javascript code. Is there any programmtical usage of esm to expose the transformed code?pkg has some "prelude" code to be executed before any other source. In there, pkg would overwrite fs and module functions (as @OmgImAlexis has mentioned earlier). So my plan is to execute esm first, and then execute the prelude code.This is fixed with Node >= 13 but PKG doesn't yet support it. Related:
Most helpful comment
Any updates?
I also came across this need, and I am doing some experiments to try to get
esmwork withpkg. Here is what I've found:pkgis usingvm.Scriptto compile source code into v8 byte code. For that to happen, I will need to get the "transformed" javascript code. Is there any programmtical usage ofesmto expose the transformed code?pkghas some "prelude" code to be executed before any other source. In there,pkgwould overwritefsandmodulefunctions (as @OmgImAlexis has mentioned earlier). So my plan is to executeesmfirst, and then execute the prelude code.