Skip to content

Commit

Permalink
feat: add support for 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
strothj committed Oct 5, 2018
1 parent 9e9c07d commit 8103a67
Show file tree
Hide file tree
Showing 3 changed files with 1,759 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/rewire/rewireTSLint.ts
Expand Up @@ -38,10 +38,10 @@ export default function(
const esLintLoaderMatcher: Matcher = rule =>
Boolean(
rule.test &&
// TODO: Remove the rule regex test that includes the JavaScript modules
// extension. Versions prior to 2.0.0-next.fb6e6f70 included support for
// JavaScript modules.
(rule.test.toString() === /\.(js|jsx|mjs)$/.toString() ||
// 2.0.4
// // https://github.com/facebook/create-react-app/commit/736561fa8b368daf27bc26646b10b8511e9d63a9
(rule.test.toString() === /\.(js|mjs|jsx)$/.toString() ||
// 2.0.2, 2.0.3
rule.test.toString() === /\.(js|jsx)$/.toString()) &&
Array.isArray(rule.use) &&
rule.use.find((r: any) => r.loader && /eslint-loader/.test(r.loader))
Expand Down
8 changes: 6 additions & 2 deletions packages/rewire/rewireWebpack.ts
Expand Up @@ -22,7 +22,7 @@ export default function(c: webpack.Configuration): webpack.Configuration {
// add TypeScript file extensions.
const scriptLoader = getLoader(config.module.rules, scriptsLoaderMatcher);
if (!scriptLoader) throw new Error("Unable to locate scripts loader.");
scriptLoader.test = /\.(ts|tsx|js|jsx)$/;
scriptLoader.test = /\.(ts|tsx|js|mjs|jsx)$/;

// Replace the babel-preset-react-app preset with the preset rewire from this
// package. This is done so @babel/preset-flow can be removed.
Expand All @@ -40,7 +40,11 @@ export default function(c: webpack.Configuration): webpack.Configuration {
const scriptsLoaderMatcher: Matcher = rule => {
return Boolean(
rule.test &&
rule.test.toString() === /\.(js|jsx)$/.toString() &&
// 2.0.2, 2.0.3
(rule.test.toString() === /\.(js|jsx)$/.toString() ||
// 2.0.4
// https://github.com/facebook/create-react-app/commit/736561fa8b368daf27bc26646b10b8511e9d63a9
rule.test.toString() === /\.(js|mjs|jsx)$/.toString()) &&
rule.enforce !== "pre" &&
typeof rule.loader === "string" &&
/babel-loader/.test(rule.loader)
Expand Down

0 comments on commit 8103a67

Please sign in to comment.