Skip to content

"default" is not exported by NativeSkiaModule.web.js #2960

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

Closed
1 task
sdcooke opened this issue Feb 13, 2025 · 5 comments · Fixed by #2963
Closed
1 task

"default" is not exported by NativeSkiaModule.web.js #2960

sdcooke opened this issue Feb 13, 2025 · 5 comments · Fixed by #2963
Labels
bug Something isn't working released

Comments

@sdcooke
Copy link

sdcooke commented Feb 13, 2025

Description

I'm building a web project with vite/esbuild and I get the following error on the latest version (1.11.7):

  [cause]: ../../node_modules/@shopify/react-native-skia/lib/module/skia/NativeSetup.js (2:7): "default" is not exported by "../../node_modules/@shopify/react-native-skia/lib/module/specs/NativeSkiaModule.web.js", imported by "../../node_modules/@shopify/react-native-skia/lib/module/skia/NativeSetup.js".
file: /Users/sam/Work/Phase/phase-monorepo/node_modules/@shopify/react-native-skia/lib/module/skia/NativeSetup.js:2:7

It looks like NativeSkiaModule.ts has a default export (https://github.com/Shopify/react-native-skia/blob/main/packages/skia/src/specs/NativeSkiaModule.ts#L9) but NativeSkiaModule.web.ts does not (https://github.com/Shopify/react-native-skia/blob/main/packages/skia/src/specs/NativeSkiaModule.web.ts). Patching the file with export default {} seems to work.

I'm not sure if the best fix would be to add the default export or change how it's being imported in NativeSetup.ts.

React Native Skia Version

1.11.7

React Native Version

0.77.0

Using New Architecture

  • Enabled

Steps to Reproduce

My project is a complex monorepo so I don't know what the most basic repro is for it, but I'm hoping it's clear from the report what's wrong here even if it doesn't happen in metro builds. I can try to create a repro if you think that's necessary.

Snack, Code Example, Screenshot, or Link to Repository

n/a

@wcandillon
Copy link
Contributor

This is a bit of a cat and mouse game. A reproduction would be useful. I would like to understand how we can prevent these errors from happening. Did you look at #2949? We use it to make sure web support works. Maybe you can add an example there? or in apps/ if you use a pure web app. Let me know.

@sdcooke
Copy link
Author

sdcooke commented Feb 14, 2025

I'll see if I can come up with a simple reproduction next week - I agree it'd be useful to be able to catch these things! My monorepo is using skia both with Expo/metro and vite as bundlers so I've hit both issues at the same time.

In the meantime, I think this one is a relatively easy fix if the .ts file has a default export and the .web.ts file doesn't?

@wcandillon
Copy link
Contributor

wcandillon commented Feb 14, 2025 via email

@sdcooke
Copy link
Author

sdcooke commented Feb 14, 2025

My expo project builds without issue as well (in the same monorepo). Without knowing a huge amount about metro and esbuild's internals (which is what vite is using at build time), my assumption is that metro doesn't check if a default export is used until runtime, but esbuild does - so esbuild is statically checking for the default export and not finding it. That's why adding export default {} is enough because it can statically check the export, but it's not actually being used at runtime.

Hopefully that makes sense, I don't think I've explained it well!

Copy link
Contributor

🎉 This issue has been resolved in version 1.11.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants