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

Fix issues on win32, regex escapes, and over-matching #3

Merged
merged 1 commit into from
Aug 27, 2019

Conversation

AprilArcus
Copy link
Contributor

@AprilArcus AprilArcus commented Aug 26, 2019

This patch fixes three issues:

  1. We were previously over-matching exceptions with the same base-name. For example, suppose I wanted to exclude react but not react-dom:

1.0.1 (wrong)

> const nodeModulesExcept = require('babel-loader-exclude-node-modules-except');
> const exceptions = nodeModulesExcept(['react']);
> 'node_modules/react/index.js'.match(exceptions);
null
> 'node_modules/react-dom/index.js'.match(exceptions);
null

This PR (correct)

> const nodeModulesExcept = require('babel-loader-exclude-node-modules-except');
> const exceptions = nodeModulesExcept(['react']);
> 'node_modules/react/index.js'.match(exceptions)
null
> 'node_modules/react-dom/index.js'.match(exceptions)
[ 'node_modules/',
  undefined,
  index: 0,
  input: 'node_modules/react-dom/index.js' ]
  1. We were previously not accommodating win32-style path separators inside module names, e.g. the forward slash inside @types/react or lodash/isequal would break when running webpack on Windows. This patch assumes POSIX-style input and reformats scoped node modules as appropriate.

  2. We were previously not performing regex escapes on the exception list, which could conceivably lead to problems. This patch adds sindresorhus/escape-string-regexp as a dependency and uses it to sanitize user input.

@AprilArcus AprilArcus force-pushed the cross-platform-fixes branch from 2680be2 to 68fd811 Compare August 26, 2019 19:24
@OlehDutchenko OlehDutchenko added the good first issue Good for newcomers label Aug 27, 2019
@OlehDutchenko OlehDutchenko merged commit 97c7f34 into OlehDutchenko:master Aug 27, 2019
@OlehDutchenko
Copy link
Owner

@AprilArcus - I'am just already updated new version at npm - 1.0.3,
and my thanks in readme.md - https://github.com/WezomAgency/babel-loader-exclude-node-modules-except#contributors-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants