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

Javascript -- v1.2.0: Reimplement esm transpilation, and swap to it as the default. #479

Merged
merged 149 commits into from Mar 17, 2024

Conversation

Skenvy
Copy link
Owner

@Skenvy Skenvy commented Mar 17, 2024

What issue is this addressing?

It would seem that previously setting the esm tsconfig's module to nodenext replaced the previously existing ems output and replaced it with two copies of the cjs output.

What type of issue is this addressing?

bug

What this PR does | solves

  • set "type": "module" and swap default main and types to the esm build.
  • Updates all actions/setup-node
  • Tightens up the .demo's npm run everything to actually test both cjs and esm instances against "CommonJS" and "ESNext" generated demo code.
  • Add loader and es-module args to mocha's rc, and added a mocha tsconfig to extend esm's with allowImportingTsExtensions
  • All tests/**.spec.ts now refer to their imports with the appropriate .ts extension.
  • All src/**.ts now refer to their imports with the appropriate .js extension (as this will be what the transpiled file's extensions will be besides the index.[c,m]js)
  • Left build:esm:ftype::wip and build:cjs:ftype::wip incase the next iteration requires automating having all .cjs files import from other .cjs files and likewise for .mjs files importing from other .mjs files. But we've got around it for now by having a package.json that specifies its type in the root of the lib/cjs and /lib/ems..

Skenvy and others added 30 commits September 27, 2022 00:22
@Skenvy Skenvy changed the title Javascript -- v1.2.0 Javascript -- v1.2.0: Reimplement ems transpilation, and swap to it as the default. Mar 17, 2024
// Call out the function before any magic returns to trap bad values.
const throwaway = (0, function_1.collatzFunction)({ n: initialValue, P: P, a: a, b: b });
const throwaway = collatzFunction({ n: initialValue, P: P, a: a, b: b });

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable throwaway.
@@ -96,7 +96,7 @@
*/
function hailstoneSequence({ initialValue, P = 2n, a = 3n, b = 1n, maxTotalStoppingTime = 1000, totalStoppingTime = true }) {
// Call out the function before any magic returns to trap bad values.
const throwaway = (0, function_1.collatzFunction)({ n: initialValue, P: P, a: a, b: b });
const throwaway = (0, function_js_1.collatzFunction)({ n: initialValue, P: P, a: a, b: b });

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable throwaway.
@Skenvy Skenvy merged commit e318518 into main Mar 17, 2024
21 checks passed
@Skenvy
Copy link
Owner Author

Skenvy commented Mar 17, 2024

This solved the issue that was blocking chai from updating the v5; see chaijs/chai#1597
Also see mochajs/mocha#4900 as this solved the issue regarding esm testing with mocha, by extending the esm tsconfig to make a mocha tsconfig with the required allowImportingTsExtensions option set. Also related was this mochajs/mocha-examples#47 set of suggested config.

@Skenvy Skenvy changed the title Javascript -- v1.2.0: Reimplement ems transpilation, and swap to it as the default. Javascript -- v1.2.0: Reimplement esm transpilation, and swap to it as the default. Mar 17, 2024
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

Successfully merging this pull request may close these issues.

None yet

1 participant