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(remix): add esm export for node #12663

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Conversation

topaxi
Copy link
Contributor

@topaxi topaxi commented Jun 26, 2024

We are running remix in ESM mode, but the exports in package.json is pointing to the CommonJS module, which results in the SDK running in CommonJS mode instead of ESM.

This lead to the instrumentations not running/detecting properly.

@onurtemizkan
Copy link
Collaborator

Thanks for the PR @topaxi, I have tested this locally, which caused the server/client trace-propagation to break on E2E tests. I'll try to check what caused that.

@onurtemizkan onurtemizkan self-assigned this Jun 27, 2024
@onurtemizkan
Copy link
Collaborator

@topaxi, could you please check if the update here solves your issue?

@topaxi
Copy link
Contributor Author

topaxi commented Jun 28, 2024

@onurtemizkan no, this will still run the package in CommonJS mode.

@topaxi
Copy link
Contributor Author

topaxi commented Jun 28, 2024

What does work for me though, is to specify the default import. I have updated the PR :)

Sadly I'm not able to install the npm dependencies locally from this repository as yarn does not succeed and playwright install tries to call apt which I do not have on my machine.

@onurtemizkan
Copy link
Collaborator

Thanks for the update @topaxi. Yes, I can see that specifying default under import does not break the current tests. But to validate that it works on tests, could you tell which instrumentations were not detected properly?

@topaxi
Copy link
Contributor Author

topaxi commented Jun 28, 2024

This was specifically for express. The logs showed that express was not instrumented, and debug: true logged that sentry was running in CommonJS mode.

Switching sentry/remix to ESM fixed it (I assume previously, sentry instrumented only the CJS versions of the package(s), which aren't actually run in the application).

Copy link
Collaborator

@onurtemizkan onurtemizkan left a comment

Choose a reason for hiding this comment

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

It doesn't seem to break anything (#12677). So it looks good to me if it resolves your issue. We'll need to revisit this when we add the worker support (For reference: #12643). But I think we can merge this in the meantime. @mydea does this make sense?

@onurtemizkan onurtemizkan requested a review from mydea July 1, 2024 11:34
@@ -28,6 +28,9 @@
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.js"
},
"import": {
"default": "./build/esm/index.server.js"
},
"node": "./build/cjs/index.server.js"
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this get split into the following?

Suggested change
"node": "./build/cjs/index.server.js"
"node": {
"import": "./build/esm/index.server.js",
"require": "./build/cjs/index.server.js"
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my initial change, see the first comment as to why that did not work.

@AbhiPrasad AbhiPrasad merged commit 747e236 into getsentry:develop Jul 2, 2024
42 checks passed
@AbhiPrasad
Copy link
Member

Thanks for the fix @topaxi!

@topaxi topaxi deleted the remix-esm branch July 3, 2024 06:06
lforst added a commit that referenced this pull request Jul 3, 2024
@lforst
Copy link
Member

lforst commented Jul 3, 2024

This change broke our E2E tests so we'll likely revert.

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

4 participants