Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Match most specific (longest) variables first #8

Merged
merged 1 commit into from
Sep 5, 2017

Conversation

mrkishi
Copy link
Contributor

@mrkishi mrkishi commented Oct 17, 2016

This fixes problems that arise when a variable name is a substring of another variable, eg. BUILD and BUILD_VERSION.

The order they are defined in the options (although ultimately decided by Object.keys()) ends up affecting the build, as the regex pattern generated is an alternation of all the variable names.

A naive solution (as used in this PR) is to simply sort the variables when creating the regex: BUILD_VERSION now takes precedence over BUILD regardless of their position in the options object.

NB: Sorry for closing the previous PR. I had accidentally reused the master branch.

This fixes problems that arise when a variable name is a substring of
another variable, eg. BUILD and BUILD_VERSION.
@mrkishi
Copy link
Contributor Author

mrkishi commented Dec 7, 2016

@Rich-Harris, friendly ping.

Just got reminded of this in a new project.

@Rich-Harris Rich-Harris merged commit 77197d9 into rollup:master Sep 5, 2017
@Rich-Harris
Copy link
Contributor

Released 1.2.1. Thanks (and apols) again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants