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

Fix source-map-support import with new NodeJS register #1265

Merged
merged 3 commits into from
May 27, 2024

Conversation

edemaine
Copy link
Collaborator

@edemaine edemaine commented May 27, 2024

Our rewrite in ESM support to NodeJS's new module register function (#1128) messed up @cspotcode/source-map-support. It seems that the registered module (esm.civet) runs in a separate Worker or other context, so it doesn't enable sourcemap support in the main thread. We had a second call to source-map-support for CJS, but it was broken because it didn't specify retrieveFile.

A result of this is we can't (easily) use a cache to share the compiled source code between the build for loading and the build for sourcemapping. I think this is fine, as we only need to recompile when dealing with an exception, which is presumably exceptional. But I kept a cache in the sourcemapping side, in case the user uses exceptions for a lot of logic or something.

Also fixed a bug in CJS require.extensions mode (which still seems important for node -r @danielx/civet/register) that didn't use sync mode.

Also removed some claims that this ESM/CJS functionality needs ts-node. This hasn't been true for a while: we compile in js: true mode.

Copy link
Contributor

@STRd6 STRd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Node ESM updates are a civet's natural enemy. 😿

@edemaine edemaine merged commit ee917ac into main May 27, 2024
3 checks passed
@edemaine edemaine deleted the source-map-support branch May 27, 2024 17:17
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.

2 participants