decentraland / decentraland-rpc

📡 Sandboxed code execution + Plugins + JSON-RPC engine
Apache License 2.0
5 stars 5 forks source link

feat: support ESM target #27

Closed belohlavek closed 5 years ago

belohlavek commented 5 years ago

This branch enables the decentraland-compiler to bundle ES modules when specified.

Example build file:

[
  {
    "name": "Compile",
    "kind": "Webpack",
    "file": "./src/index.ts",
    "target": "esm",
    "library": "ethconnect"
  }
]

Where target must be esm for the feature to be enabled and library refers to the library name that will also be the variable exported by the module itself.

Logic-wise, Webpack does not support targeting ESM so the implemented workaround involves targeting var (the whole bundle contained in a variable) and exporting that variable using the ES module syntax.

This change allows eth-connect to be bundled and consumed inside DCL's parcels.