Skip to content

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

Merged
Skenvy merged 149 commits intomainfrom
javascript
Mar 17, 2024
Merged

Javascript -- v1.2.0: Reimplement esm transpilation, and swap to it as the default.#479
Skenvy merged 149 commits intomainfrom
javascript

Conversation

@Skenvy
Copy link
Copy Markdown
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
export 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 = collatzFunction({ n: initialValue, P: P, a: a, b: b });

Check notice

Code scanning / CodeQL

Unused variable, import, function or class

Unused variable throwaway.
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

Unused variable throwaway.
@Skenvy Skenvy merged commit e318518 into main Mar 17, 2024
@Skenvy
Copy link
Copy Markdown
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.

1 participant