-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat(compartment-mapper): Thread commonjs- and module- languageForExtension options (for TS) #2625
feat(compartment-mapper): Thread commonjs- and module- languageForExtension options (for TS) #2625
Conversation
071e61e
to
6d146a4
Compare
caffdaa
to
0a25959
Compare
6d146a4
to
905d9da
Compare
0a25959
to
42b8b18
Compare
errorTrapping: 'none', | ||
}); | ||
|
||
scaffold( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers new to Compartment Mapper, scaffold
generates a combination of test cases where a single fixture is expected to produce the same behavior for multiple flows:
- executed directly off a file system
- loaded off the file system then later executed
- archived off the file system, then parsed, then executed
&c
f77329b
to
d6ce6de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'm new to this package so I don't have an opinion on the design decisions. The code changes all look good.
mjs: 'mjs', | ||
cjs: 'cjs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider alphabetizing or leaving where it was
); | ||
} | ||
const invalidLanguages = values(packageLanguageForExtension).filter( | ||
language => !languages.has(language), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
language
and languages
look very similar. consider,
language => !languages.has(language), | |
l => !languages.has(l), |
60b295c
to
300f46c
Compare
…ized on package type
300f46c
to
389de7b
Compare
Closes: #2415 ## Description This change introduces support for TypeScript through type-erasure, using ts-blank-space, which converts type annotations to equivalent blank space. As is consistent with `node --experimental-strip-types`, this only applies to modules with the `.ts`, `.mts`, or `.cts` extensions in packages that are not under `node_modules`, to discourage publishing TypeScript as a source language to npm. ### Security Considerations The choice of `ts-blank-space` is intended to minimize runtime behavior difference between TypeScript and JavaScript, such that a reviewer or a debugger of the generated JavaScript aligns with the expected behavior and original text, to the extent that is possible. This should compose well with #2444. ### Scaling Considerations None. ### Documentation Considerations Contains README and NEWS. ### Testing Considerations Contains spot check tests for TypeScript in the endoScript and endoZipBase64 formats. We stand on much more rigorous testing of the underlying workspace-language-for-extension feature in Compartment Mapper #2625. ### Compatibility Considerations This does not break any prior usage. ### Upgrade Considerations None.
Refs: #2415
Description
Toward support for type-erasure style TypeScript support in Endo,
.ts
files may correspond to.mts
or.cts
behavior in the same way that.js
can correspond to either.mjs
or.cjs
, depending on"type":
in the envelopingpackage.json
(which is not necessarily the enveloping package, e.g.,src/package.json
beneathpackage.json
!). We already implement this machinery for JavaScript, so this change threads additional options besidelanguageForExtension
(which would map.mts
and.cts
to language behaviors) but alsocommonjsLanguageForExtension
andmoduleLanguageForExtension
, which would get folded into the language-for-extension mapping on a package-by-package basis.Security Considerations
None. Absent from this design is any possibility that a file would be alternately implemented as TypeScript or JavaScript.
Scaling Considerations
None.
Documentation Considerations
Includes an update to README for the new features and the undocumented features it is based upon. Includes a mention in NEWS.
Testing Considerations
TODO
Compatibility Considerations
By design error,
languageForExtension
threaded throughlink
before this change, when it should have been threaded throughmapNodeModules
, since that is the machine that is aware of thetype
field inpackage.json
. This change moves that internal mechanism and then addscommonjsLanguageForExtension
andmoduleLanguageForExtension
. By common usage, this move is transparent since the option is taken at the top and simply diverted internally.However, the
languageForExtension
property could be manually threaded throughmakeArchiveLite
and omitted from the options formapNodeModules
. I’ve elected to treat this breaking change as a bug fix since I find it unlikely anyone has taken advantage of these relatively new “lite” functions. The “lite” functions are part of the refactoring necessary to approach native XS compartment and modules.Upgrade Considerations
None.