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

Error: Option 'mapper' isn't supported by the Node crawler #418

Open
vicki15 opened this issue Jun 14, 2019 · 3 comments
Open

Error: Option 'mapper' isn't supported by the Node crawler #418

vicki15 opened this issue Jun 14, 2019 · 3 comments

Comments

@vicki15
Copy link

vicki15 commented Jun 14, 2019

Do you want to request a feature or report a bug?
Report a bug

Repro steps
I'm running Metro.runBuild() and getting the error
Loading dependency graph...Failed to construct transformer: Error: Option 'mapper' isn't supported by the Node crawler at nodeCrawl (/****/node_modules/metro/node_modules/jest-haste-map/build/crawlers/node.js:227:11) at HasteMap._crawl (/***/node_modules/metro/node_modules/jest-haste-map/build/index.js:1021:14) at /***/node_modules/metro/node_modules/jest-haste-map/build/index.js:572:21

Note: this only repro's with watchman disabled.

resolver: { useWatchman: false }

What is the expected behavior?
No errors when bundling ;)

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
metro.config.js

const blacklist = require('metro-config/src/defaults/blacklist');
const path = require("path")

module.exports = {
    resolver: {
        useWatchman: false,
        blacklistRE: blacklist([
            /node_modules\/.*\/node_modules\/react-native\/.*/,
            /build\/private\/tmp\/.*/,
        ]),
        extraNodeModules: {
          "react-native": path.resolve("node_modules/react-native"),
          "@babel/runtime": path.resolve("node_modules/@babel/runtime"),

        },
        hasteImplModulePath: path.resolve('node_modules/react-native/jest/hasteImpl.js'),
    },
    transformer: {
        babelTransformerPath: path.resolve('node_modules/metro-react-native-babel-transformer/src/index'),
        assetRegistryPath: path.resolve('node_modules/react-native/Libraries/Image/AssetRegistry'),
    },
    serializer: {
        getModulesRunBeforeMainModule: () => [
            path.resolve('node_modules/react-native/Libraries/Core/InitializeCore.js')
        ],
        getPolyfills: require(path.resolve('node_modules/react-native/rn-get-polyfills')),
    },
    resetCache: true
};

metro version "metro": "0.54.0"

How to fix
Note: This is caused by a bug in jest-haste-map that was fixed 2 days ago, so metro needs to update their dependency to the latest version of jest-haste-map - where they no longer throw this error and simply ignore the config option. This should fix the error! Otherwise - I am not sure where the 'mapper' option is being passed through, I assume this is somewhere in the metro code and should be removed.
jestjs/jest#8558

@mikehardy
Copy link
Contributor

Until jest (or jest-haste-map) does a release that is integrated here you can use this (without the .txt extension I needed for github) in combination with patch-package to move forward
jest-haste-map+24.8.0.patch.txt

@alfonsojbro
Copy link

Have you found a better answer? I have been struggling with this problem for days now and have not been able to solve it.

@mikehardy
Copy link
Contributor

I don't believe current versions of anything have this problem. I'd forgotten about it and no longer have the patch integrated. I'm on react-native 0.61.x now, so I think the answer is patch until you get current.

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

No branches or pull requests

3 participants