How to correctly define Node.js functions and properties for Prepack?

I want to use prepackNPM in my package, but I get errors like require is not definedand module is not defined.

I tried to define variables such as:

__assumeDataProperty(global, 'require', __abstract('function'))

but i get an error unknown reference type

How can I correctly define global functions and properties Node.jsfor prepack?

+4
source share
1 answer

TL; DR; Use compatibility modenode-cli

$ prepack sourcefile.js --compatibility node-cli

However, at the moment it is only available on Node 7.9 .

Here is an explanation of this:

require __abstract('function'), prepack, , , . , , require . , , : .

, , , , , . , PR PoC, , Node API, . , Node 7.9.

, :)

0

Source: https://habr.com/ru/post/1676827/


All Articles