Skip to content

Commit

Permalink
Fix building in paths containing even more special characters
Browse files Browse the repository at this point in the history
Summary:
rollup-pluginutils scopes include/exclude patterns provided to the current directory by prefixing the pattern with the current path.
Unfortunately, if that path contains special characters that have an effect in regular expressions, they're not treated as literal.
There's a bug open against this behaviour: rollup/rollup-pluginutils#39
Workaround it by providing include/exclude as regular expressions, which doesn't trigger this behaviour.

Test Plan: Build in a directory named "qa^(2),2"

Reviewers: #developer_tools, Jupiter, csnider

Reviewed By: #developer_tools, Jupiter, csnider

Subscribers: csnider

JIRA Issues: IPD-102765

Differential Revision: https://phabricator.firmwareci.fitbit.com/D2258
  • Loading branch information
Hexxeh committed Sep 26, 2018
1 parent 63fa818 commit f406cf9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-pluginutils": "2.3.2",
"rollup-pluginutils": "^2.3.3",
"semver": "^5.5.0",
"simple-random": "^1.0.3",
"source-map": "^0.7.3",
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { default as tslib } from './tslib.const';
import { Diagnostic } from '../../diagnostics';

interface IOptions {
include: string | string[];
exclude: string | string[];
include: string | string[] | RegExp | RegExp[];
exclude: string | string[] | RegExp | RegExp[];
tsconfig?: string;
tsconfigOverride?: ts.CompilerOptions;
onDiagnostic: (diagnostic: Diagnostic) => void;
Expand Down Expand Up @@ -39,8 +39,11 @@ const generateMessage = (tsDiagnostic: ts.Diagnostic) => {

export default function typescript(options?: Partial<IOptions>): Plugin {
const pluginOptions: IOptions = {
include: ['*.(t|j)s+(|x)', '**/*.(t|j)s+(|x)'],
exclude: ['*.d.ts', '**/*.d.ts', 'node_modules/**'],
// Defined as a regex to avoid buggy scoping where regex special chars in CWD
// are incorrectly considered as part of the match pattern.
// https://github.com/rollup/rollup-pluginutils/issues/39
include: /\.[tj]sx?$/,
exclude: [/\.d\.ts$/, /\/node_modules\//],
tsconfig: undefined,
tsconfigOverride: undefined,
onDiagnostic: () => {},
Expand Down
3 changes: 2 additions & 1 deletion src/types/rollup-pluginutils/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace rollupPluginUtils {
function createFilter(include: string | string[], exclude: string | string[]): (id: string) => boolean;
type Filter = string | string[] | RegExp | RegExp[];
function createFilter(include: Filter, exclude: Filter): (id: string) => boolean;
}
export = rollupPluginUtils;
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3979,13 +3979,6 @@ rollup-plugin-node-resolve@^3.3.0:
is-module "^1.0.0"
resolve "^1.1.6"

rollup-pluginutils@2.3.2:
version "2.3.2"
resolved "https://artifacts.site-ops.fitbit.com:443/artifactory/api/npm/npm-virtual/rollup-pluginutils/-/rollup-pluginutils-2.3.2.tgz#78d99a0a4baa281c80e23e5d911251ed5ab27d4f"
dependencies:
estree-walker "^0.5.2"
micromatch "^3.1.10"

rollup-pluginutils@^1.5.0:
version "1.5.2"
resolved "https://artifacts.site-ops.fitbit.com:443/artifactory/api/npm/npm-virtual/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz#1e156e778f94b7255bfa1b3d0178be8f5c552408"
Expand All @@ -4000,6 +3993,13 @@ rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.2.0:
estree-walker "^0.5.2"
micromatch "^2.3.11"

rollup-pluginutils@^2.3.3:
version "2.3.3"
resolved "https://artifacts.site-ops.fitbit.com:443/artifactory/api/npm/npm-virtual/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794"
dependencies:
estree-walker "^0.5.2"
micromatch "^2.3.11"

rollup@^0.54.0:
version "0.54.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.54.1.tgz#415a5d999421502646cf54b873fc4ce1a7393970"
Expand Down

0 comments on commit f406cf9

Please sign in to comment.