kristerkari / react-native-sass-transformer

Use Sass to style your React Native apps.
MIT License
219 stars 19 forks source link

Manual Metro dependency installation breaks build #20

Closed dnsmob closed 5 years ago

dnsmob commented 5 years ago

This is more of a heads up rather than an issue. This lib works fine if I create a project via react-native command, but if I manually install the metro bundler (via npm i metro), the latest/current version does not match the file dependencies, and it then breaks this transformer. Obvious fix is to just install the exact version, but at some point RN will be using the latest Metro too.

RN cli uses metro 0.49.2 npm i will install metro 0.51.1

kristerkari commented 5 years ago

Thanks! Any idea which changes are needed for the new Metro version?

dnsmob commented 5 years ago

With Metro 0.51.1 it borks when trying to access this
UnhandledPromiseRejectionWarning: Error: Cannot find module 'metro/src/reactNativeTransformer'

kristerkari commented 5 years ago

So the error happens because the transformer path has changed in the newest Metro version and is going to be like that in React Native 0.59.

I released a new version (v.1.3.2) of this transformer that uses the new path for React Native 0.59.

If you want to use a custom version with Metro for your current project, then I recommend using Metro v0.49.2 for now and updating that to 0.51.1 when updating to use React Native 0.59.

kristerkari commented 5 years ago

Oh yeah and thanks a lot for notifying me about this! :)

palexs commented 5 years ago

@kristerkari In my case I had to change const transformer = require('metro/src/reactNativeTransformer'); to const transformer = require('metro-babel-transformer');, as they've put the transformer into a separate module.

kristerkari commented 5 years ago

@palexs yeah, that's what the latest version the Sass transformer is also doing: https://github.com/kristerkari/react-native-sass-transformer/blob/master/index.js#L13-L14