Skip to content

Update documentation for expo-web example #1278

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-paws-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@segment/analytics-next': patch
---

Updated docs for expo-web example
35 changes: 35 additions & 0 deletions packages/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,41 @@ export default defineComponent({
</script>
```

### Expo Web
Expo web leverages Metro as it's bundler. Since Analytics.js ships as a precompiled library we will want to ignore any transformations to avoid running into an error on build.

1. Setup the custom transformer in `metro.config.js`

```js
module.exports = {
...config,
transformer: {
...transformer,
babelTransformerPath: require.resolve('./metroTransformer.cjs'),
}
// Your other metro config options
}
```

2. Create a new `metroTransformer.js`

```js

const { transform } = require('metro-babel-transformer')

module.exports.transform = async function customTransform(props) {
// Skipping transformation for precompiled file
if (
props.filename.includes('node_modules/@segment/analytics-next')
) {
return { code: props.src, map: null }
}

return await transform(props)
}
```


## Support for Web Workers (Experimental)
While this package does not support web workers out of the box, there are options:

Expand Down