Re-exporting all exports of a module that was compiled with Rollup or Babel and overriding one of the exports causes a TypeError because Reify attempts to set a read-only property in the exports object. Reproduction repository: https://github.com/klaussner/reify-issue-236.
If the output is used like this with Reify, a TypeError is thrown:
export * from "./rollup-output";
export const existsSync = ":)";
TypeError: Cannot set property existsSync of #<Object> which has only a getter
at Entry.Ep.runGetters (node_modules/reify/lib/runtime/entry.js:165:33)
at Entry.Ep.runSetters (node_modules/reify/lib/runtime/entry.js:211:8)
at Module.runSetters (node_modules/reify/lib/runtime/index.js:115:36)
at Object.extWrap (node_modules/reify/node/compile-hook.js:57:9)
at Object.extManager (node_modules/reify/node/compile-hook.js:19:12)
at Object.manager [as .js] (node_modules/reify/node/wrapper.js:108:20)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
I think we could solve this by also using Object.defineProperty in the runtime code that sets properties on the exports object (potentially only after simple assignment throws).
Re-exporting all exports of a module that was compiled with Rollup or Babel and overriding one of the exports causes a
TypeError
because Reify attempts to set a read-only property in theexports
object. Reproduction repository: https://github.com/klaussner/reify-issue-236.Rollup input:
Rollup output (Babel output is similar):
If the output is used like this with Reify, a
TypeError
is thrown: