Skip to content

Fix haste module resolution inside of scoped modules (Fixes #241)#249

Closed
empyrical wants to merge 3 commits into
react:masterfrom
empyrical:haste-scoped-packages
Closed

Fix haste module resolution inside of scoped modules (Fixes #241)#249
empyrical wants to merge 3 commits into
react:masterfrom
empyrical:haste-scoped-packages

Conversation

@empyrical

Copy link
Copy Markdown
Contributor

Summary

This (WIP!) pull request attempts to fix issues with Haste and scoped modules.

It is a WIP, because I was able to figure out how to get it working on Posix - but I still need to work out what the issue is on Win32.

Test plan

Test cases for posix and win32 have been added to traverseDependencies-integration-test.js.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 14, 2018
@empyrical

Copy link
Copy Markdown
Contributor Author

Figured out the win32 problem. This requires a fix to jest-haste-map, and have made a pull request:

jestjs/jest#6980

Once it is merged and a version of jest-haste-map with it is released, this PR can be updated with it and the win32 issue will be resolved.

dgraph,
'C:\\root\\index.js',
);
console.error(deps)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can you remove the console.error()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, forgot that debug line there! Fixed it up.

@rafeca

rafeca commented Sep 15, 2018

Copy link
Copy Markdown
Contributor

Wow thanks a lot for the PR 😍

Codewise LGTM, can you run prettier to get the linter happy? (I guess that the failing tests will get fixed with the new version of jest-haste-map.

@empyrical

Copy link
Copy Markdown
Contributor Author

Prettified, and cleaned up the debug line

@empyrical

Copy link
Copy Markdown
Contributor Author

So because jest-haste-map had a breaking change in it recently, it is warned that my change might not land in a release for some time.

There is a way to go for fixing windows support in the meantime, but I'd like your input @rafeca before I push it to this PR.

If I include the patched version of getWhiteList with Metro, and manually swap out the private _whitelist property with a patched version, the Win32 test will pass.

Example:

  static _createHaste(opts: Options): JestHasteMap {
    const hasteMap = new JestHasteMap({
      // ... trimed ...
    });
    hasteMap._whiteList = getWhiteList(opts.providesModuleNodeModules);
    return hasteMap;
  }

An issue would then have to be created to remind to remove this patch when jest-haste-map is updated.

@rafeca

rafeca commented Sep 15, 2018

Copy link
Copy Markdown
Contributor

There is a way to go for fixing windows support in the meantime, but I'd like your input @rafeca before I push it to this PR.

I'd prefer to avoid patching jest-haste-map... can we instead disable the test in win32 until we get a new version of jest-haste-map published? (I'll add this as a known issue in the release notes).

I think I can convince @mjesun to publish a new version of jest-haste-map 😆

@empyrical

Copy link
Copy Markdown
Contributor Author

Skipped the test for now, and CI looks good now! 👌

@empyrical empyrical changed the title [WIP] Fix haste module resolution inside of scoped modules (Fixes #241) Fix haste module resolution inside of scoped modules (Fixes #241) Sep 15, 2018

@rafeca rafeca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yay!! Thanks a lot for this PR 🎉

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rafeca is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants