Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated TypeScript throws with frozen intrinsics #25

Open
kriskowal opened this issue Mar 31, 2021 · 0 comments
Open

Generated TypeScript throws with frozen intrinsics #25

kriskowal opened this issue Mar 31, 2021 · 0 comments

Comments

@kriskowal
Copy link

When running the compiled JS in the presence of a frozen Function.prototype, this module throws on initialization Cannot assign to read only property 'constructor' of object. This is because the TypeScript compiler, when targeting ES5, uses property assignment to replace the prototype.constructor.

The motivation for freezing all of the shared intrinsic objects is that, in conjunction with compartmentalization of third-party dependencies, it is possible to mitigate some classes of supply chain attack. https://github.com/endojs/endo/tree/master/packages/ses#secure-ecmascript-ses

This can be solved with a change and possibly an upgrade to the TypeScript compiler, if they are amenable to the change. microsoft/TypeScript#43450

This can alternately be solved by either

  • moving the language target up to ES2015 (which is technically a breaking change), patching after-the-build (messy),
  • or creating a secondary build target for ESM and multiplexing package.json with a module property (for RESM https://github.com/standard-things/esm) and an imports property (for Node.js 12+).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant