From 2426796445b154b6aa0ead12880f26ebafefce6c Mon Sep 17 00:00:00 2001 From: Dilan Date: Fri, 1 Jul 2022 15:19:44 -0500 Subject: [PATCH] remove dist on non-typescript version --- dist/bin/craco.d.ts | 2 - dist/bin/craco.js | 37 ---- dist/bin/jest.d.ts | 2 - dist/bin/jest.js | 26 --- dist/index.d.ts | 9 - dist/index.js | 41 ---- dist/lib/args.d.ts | 4 - dist/lib/args.js | 49 ----- dist/lib/asset-modules.d.ts | 29 --- dist/lib/asset-modules.js | 86 -------- dist/lib/config.d.ts | 5 - dist/lib/config.js | 156 -------------- dist/lib/cra.d.ts | 21 -- dist/lib/cra.js | 200 ------------------ dist/lib/features/dev-server/api.d.ts | 4 - dist/lib/features/dev-server/api.js | 37 ---- .../create-config-provider-proxy.d.ts | 3 - .../create-config-provider-proxy.js | 47 ---- .../features/dev-server/override-utils.d.ts | 3 - .../lib/features/dev-server/override-utils.js | 38 ---- dist/lib/features/dev-server/override.d.ts | 3 - dist/lib/features/dev-server/override.js | 14 -- .../dev-server/set-environment-variables.d.ts | 2 - .../dev-server/set-environment-variables.js | 37 ---- dist/lib/features/jest/api.d.ts | 4 - dist/lib/features/jest/api.js | 39 ---- .../jest/create-jest-babel-transform.d.ts | 2 - .../jest/create-jest-babel-transform.js | 67 ------ .../features/jest/jest-babel-transform.d.ts | 1 - .../lib/features/jest/jest-babel-transform.js | 73 ------- dist/lib/features/jest/merge-jest-config.d.ts | 3 - dist/lib/features/jest/merge-jest-config.js | 87 -------- dist/lib/features/jest/override.d.ts | 3 - dist/lib/features/jest/override.js | 17 -- dist/lib/features/plugins.d.ts | 138 ------------ dist/lib/features/plugins.js | 115 ---------- dist/lib/features/webpack/api.d.ts | 6 - dist/lib/features/webpack/api.js | 47 ---- dist/lib/features/webpack/babel.d.ts | 4 - dist/lib/features/webpack/babel.js | 84 -------- dist/lib/features/webpack/eslint.d.ts | 4 - dist/lib/features/webpack/eslint.js | 107 ---------- .../webpack/merge-webpack-config.d.ts | 4 - .../features/webpack/merge-webpack-config.js | 122 ----------- dist/lib/features/webpack/override.d.ts | 4 - dist/lib/features/webpack/override.js | 17 -- dist/lib/features/webpack/style/css.d.ts | 4 - dist/lib/features/webpack/style/css.js | 75 ------- dist/lib/features/webpack/style/postcss.d.ts | 4 - dist/lib/features/webpack/style/postcss.js | 120 ----------- dist/lib/features/webpack/style/sass.d.ts | 4 - dist/lib/features/webpack/style/sass.js | 64 ------ dist/lib/features/webpack/style/style.d.ts | 4 - dist/lib/features/webpack/style/style.js | 15 -- dist/lib/features/webpack/typescript.d.ts | 3 - dist/lib/features/webpack/typescript.js | 20 -- dist/lib/loaders.d.ts | 29 --- dist/lib/loaders.js | 168 --------------- dist/lib/logger.d.ts | 2 - dist/lib/logger.js | 47 ---- dist/lib/paths.d.ts | 1 - dist/lib/paths.js | 10 - dist/lib/plugin-utils.d.ts | 3 - dist/lib/plugin-utils.js | 38 ---- dist/lib/user-config-utils.d.ts | 4 - dist/lib/user-config-utils.js | 22 -- dist/lib/utils.d.ts | 5 - dist/lib/utils.js | 57 ----- dist/lib/validate-cra-version.d.ts | 2 - dist/lib/validate-cra-version.js | 16 -- dist/lib/webpack-plugins.d.ts | 11 - dist/lib/webpack-plugins.js | 96 --------- dist/scripts/build.d.ts | 1 - dist/scripts/build.js | 22 -- dist/scripts/start.d.ts | 1 - dist/scripts/start.js | 24 --- dist/scripts/test.d.ts | 1 - dist/scripts/test.js | 22 -- dist/types/args.d.ts | 9 - dist/types/args.js | 2 - dist/types/asset-modules.d.ts | 7 - dist/types/asset-modules.js | 2 - dist/types/config.d.ts | 82 ------- dist/types/config.js | 2 - dist/types/context.d.ts | 37 ---- dist/types/context.js | 2 - dist/types/loaders.d.ts | 12 -- dist/types/loaders.js | 2 - dist/types/plugin-utils.d.ts | 6 - dist/types/plugin-utils.js | 2 - dist/types/plugins.d.ts | 35 --- dist/types/plugins.js | 2 - 92 files changed, 2900 deletions(-) delete mode 100644 dist/bin/craco.d.ts delete mode 100644 dist/bin/craco.js delete mode 100644 dist/bin/jest.d.ts delete mode 100644 dist/bin/jest.js delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/lib/args.d.ts delete mode 100644 dist/lib/args.js delete mode 100644 dist/lib/asset-modules.d.ts delete mode 100644 dist/lib/asset-modules.js delete mode 100644 dist/lib/config.d.ts delete mode 100644 dist/lib/config.js delete mode 100644 dist/lib/cra.d.ts delete mode 100644 dist/lib/cra.js delete mode 100644 dist/lib/features/dev-server/api.d.ts delete mode 100644 dist/lib/features/dev-server/api.js delete mode 100644 dist/lib/features/dev-server/create-config-provider-proxy.d.ts delete mode 100644 dist/lib/features/dev-server/create-config-provider-proxy.js delete mode 100644 dist/lib/features/dev-server/override-utils.d.ts delete mode 100644 dist/lib/features/dev-server/override-utils.js delete mode 100644 dist/lib/features/dev-server/override.d.ts delete mode 100644 dist/lib/features/dev-server/override.js delete mode 100644 dist/lib/features/dev-server/set-environment-variables.d.ts delete mode 100644 dist/lib/features/dev-server/set-environment-variables.js delete mode 100644 dist/lib/features/jest/api.d.ts delete mode 100644 dist/lib/features/jest/api.js delete mode 100644 dist/lib/features/jest/create-jest-babel-transform.d.ts delete mode 100644 dist/lib/features/jest/create-jest-babel-transform.js delete mode 100644 dist/lib/features/jest/jest-babel-transform.d.ts delete mode 100644 dist/lib/features/jest/jest-babel-transform.js delete mode 100644 dist/lib/features/jest/merge-jest-config.d.ts delete mode 100644 dist/lib/features/jest/merge-jest-config.js delete mode 100644 dist/lib/features/jest/override.d.ts delete mode 100644 dist/lib/features/jest/override.js delete mode 100644 dist/lib/features/plugins.d.ts delete mode 100644 dist/lib/features/plugins.js delete mode 100644 dist/lib/features/webpack/api.d.ts delete mode 100644 dist/lib/features/webpack/api.js delete mode 100644 dist/lib/features/webpack/babel.d.ts delete mode 100644 dist/lib/features/webpack/babel.js delete mode 100644 dist/lib/features/webpack/eslint.d.ts delete mode 100644 dist/lib/features/webpack/eslint.js delete mode 100644 dist/lib/features/webpack/merge-webpack-config.d.ts delete mode 100644 dist/lib/features/webpack/merge-webpack-config.js delete mode 100644 dist/lib/features/webpack/override.d.ts delete mode 100644 dist/lib/features/webpack/override.js delete mode 100644 dist/lib/features/webpack/style/css.d.ts delete mode 100644 dist/lib/features/webpack/style/css.js delete mode 100644 dist/lib/features/webpack/style/postcss.d.ts delete mode 100644 dist/lib/features/webpack/style/postcss.js delete mode 100644 dist/lib/features/webpack/style/sass.d.ts delete mode 100644 dist/lib/features/webpack/style/sass.js delete mode 100644 dist/lib/features/webpack/style/style.d.ts delete mode 100644 dist/lib/features/webpack/style/style.js delete mode 100644 dist/lib/features/webpack/typescript.d.ts delete mode 100644 dist/lib/features/webpack/typescript.js delete mode 100644 dist/lib/loaders.d.ts delete mode 100644 dist/lib/loaders.js delete mode 100644 dist/lib/logger.d.ts delete mode 100644 dist/lib/logger.js delete mode 100644 dist/lib/paths.d.ts delete mode 100644 dist/lib/paths.js delete mode 100644 dist/lib/plugin-utils.d.ts delete mode 100644 dist/lib/plugin-utils.js delete mode 100644 dist/lib/user-config-utils.d.ts delete mode 100644 dist/lib/user-config-utils.js delete mode 100644 dist/lib/utils.d.ts delete mode 100644 dist/lib/utils.js delete mode 100644 dist/lib/validate-cra-version.d.ts delete mode 100644 dist/lib/validate-cra-version.js delete mode 100644 dist/lib/webpack-plugins.d.ts delete mode 100644 dist/lib/webpack-plugins.js delete mode 100644 dist/scripts/build.d.ts delete mode 100644 dist/scripts/build.js delete mode 100644 dist/scripts/start.d.ts delete mode 100644 dist/scripts/start.js delete mode 100644 dist/scripts/test.d.ts delete mode 100644 dist/scripts/test.js delete mode 100644 dist/types/args.d.ts delete mode 100644 dist/types/args.js delete mode 100644 dist/types/asset-modules.d.ts delete mode 100644 dist/types/asset-modules.js delete mode 100644 dist/types/config.d.ts delete mode 100644 dist/types/config.js delete mode 100644 dist/types/context.d.ts delete mode 100644 dist/types/context.js delete mode 100644 dist/types/loaders.d.ts delete mode 100644 dist/types/loaders.js delete mode 100644 dist/types/plugin-utils.d.ts delete mode 100644 dist/types/plugin-utils.js delete mode 100644 dist/types/plugins.d.ts delete mode 100644 dist/types/plugins.js diff --git a/dist/bin/craco.d.ts b/dist/bin/craco.d.ts deleted file mode 100644 index b7988016..00000000 --- a/dist/bin/craco.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -export {}; diff --git a/dist/bin/craco.js b/dist/bin/craco.js deleted file mode 100644 index 14c36fbe..00000000 --- a/dist/bin/craco.js +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env node -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -var cross_spawn_1 = __importDefault(require("cross-spawn")); -var args = process.argv.slice(2); -var scriptIndex = args.findIndex(function (x) { return x === 'build' || x === 'start' || x === 'test'; }); -var script = scriptIndex === -1 ? args[0] : args[scriptIndex]; -switch (script) { - case 'build': - case 'start': - case 'test': { - var nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []; - var scriptPath = require.resolve("../scripts/".concat(script)); - var scriptArgs = args.slice(scriptIndex + 1); - var processArgs = nodeArgs.concat(scriptPath).concat(scriptArgs); - var child = cross_spawn_1.default.sync('node', processArgs, { stdio: 'inherit' }); - if (child.signal) { - if (child.signal === 'SIGKILL') { - console.log("\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n `kill -9` on the process.\n "); - } - else if (child.signal === 'SIGTERM') { - console.log("\n The build failed because the process exited too early.\n Someone might have called `kill` or `killall`, or the system could\n be shutting down.\n "); - } - process.exit(1); - } - process.exit((_a = child.status) !== null && _a !== void 0 ? _a : undefined); - break; - } - default: - console.log("Unknown script \"".concat(script, "\".")); - console.log('Perhaps you need to update craco?'); - break; -} diff --git a/dist/bin/jest.d.ts b/dist/bin/jest.d.ts deleted file mode 100644 index b7988016..00000000 --- a/dist/bin/jest.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -export {}; diff --git a/dist/bin/jest.js b/dist/bin/jest.js deleted file mode 100644 index add011ef..00000000 --- a/dist/bin/jest.js +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env node -"use strict"; -/* - * Copied (and converted to TS) from https://github.com/timarney/react-app-rewired/blob/master/packages/react-app-rewired/bin/jest.js - - * This file is necessary to allow usage of craco as a drop-in replacement - * for react-scripts with WebStorms's test runner UI. - * - * For more information, see https://github.com/sharegate/craco/pull/41 - */ -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -var cross_spawn_1 = __importDefault(require("cross-spawn")); -var args = process.argv.slice(2); -var setupScriptFileIndex = args.findIndex(function (x) { return x === '--setupTestFrameworkScriptFile'; }) + 1; -var isIntelliJ = setupScriptFileIndex !== -1 - ? false - : args[setupScriptFileIndex].indexOf('jest-intellij') !== -1; -var result = cross_spawn_1.default.sync(process.argv[0], [].concat(require.resolve('../scripts/test'), args), { - stdio: 'inherit', - env: Object.assign({}, process.env, isIntelliJ ? { CI: 1 } : null), -}); -process.exit(result.signal ? 1 : (_a = result.status) !== null && _a !== void 0 ? _a : undefined); diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index af2ddb34..00000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { addAfterAssetModule, addAfterAssetModules, addBeforeAssetModule, addBeforeAssetModules, assetModuleByName, getAssetModule, getAssetModules, removeAssetModules } from './lib/asset-modules'; -import { createDevServerConfigProviderProxy } from './lib/features/dev-server/api'; -import { createJestConfig } from './lib/features/jest/api'; -import { createWebpackDevConfig, createWebpackProdConfig } from './lib/features/webpack/api'; -import { addAfterLoader, addAfterLoaders, addBeforeLoader, addBeforeLoaders, getLoader, getLoaders, loaderByName, removeLoaders } from './lib/loaders'; -import { gitHubIssueUrl, throwUnexpectedConfigError } from './lib/plugin-utils'; -import { when, whenDev, whenProd, whenTest } from './lib/user-config-utils'; -import { addPlugins, getPlugin, pluginByName, removePlugins } from './lib/webpack-plugins'; -export { getLoader, getLoaders, removeLoaders, addBeforeLoader, addBeforeLoaders, addAfterLoader, addAfterLoaders, loaderByName, getAssetModule, getAssetModules, removeAssetModules, addBeforeAssetModule, addBeforeAssetModules, addAfterAssetModule, addAfterAssetModules, assetModuleByName, getPlugin, pluginByName, addPlugins, removePlugins, when, whenDev, whenProd, whenTest, throwUnexpectedConfigError, gitHubIssueUrl, createJestConfig, createWebpackDevConfig, createWebpackProdConfig, createDevServerConfigProviderProxy, }; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 1374e4e7..00000000 --- a/dist/index.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createDevServerConfigProviderProxy = exports.createWebpackProdConfig = exports.createWebpackDevConfig = exports.createJestConfig = exports.gitHubIssueUrl = exports.throwUnexpectedConfigError = exports.whenTest = exports.whenProd = exports.whenDev = exports.when = exports.removePlugins = exports.addPlugins = exports.pluginByName = exports.getPlugin = exports.assetModuleByName = exports.addAfterAssetModules = exports.addAfterAssetModule = exports.addBeforeAssetModules = exports.addBeforeAssetModule = exports.removeAssetModules = exports.getAssetModules = exports.getAssetModule = exports.loaderByName = exports.addAfterLoaders = exports.addAfterLoader = exports.addBeforeLoaders = exports.addBeforeLoader = exports.removeLoaders = exports.getLoaders = exports.getLoader = void 0; -var asset_modules_1 = require("./lib/asset-modules"); -Object.defineProperty(exports, "addAfterAssetModule", { enumerable: true, get: function () { return asset_modules_1.addAfterAssetModule; } }); -Object.defineProperty(exports, "addAfterAssetModules", { enumerable: true, get: function () { return asset_modules_1.addAfterAssetModules; } }); -Object.defineProperty(exports, "addBeforeAssetModule", { enumerable: true, get: function () { return asset_modules_1.addBeforeAssetModule; } }); -Object.defineProperty(exports, "addBeforeAssetModules", { enumerable: true, get: function () { return asset_modules_1.addBeforeAssetModules; } }); -Object.defineProperty(exports, "assetModuleByName", { enumerable: true, get: function () { return asset_modules_1.assetModuleByName; } }); -Object.defineProperty(exports, "getAssetModule", { enumerable: true, get: function () { return asset_modules_1.getAssetModule; } }); -Object.defineProperty(exports, "getAssetModules", { enumerable: true, get: function () { return asset_modules_1.getAssetModules; } }); -Object.defineProperty(exports, "removeAssetModules", { enumerable: true, get: function () { return asset_modules_1.removeAssetModules; } }); -var api_1 = require("./lib/features/dev-server/api"); -Object.defineProperty(exports, "createDevServerConfigProviderProxy", { enumerable: true, get: function () { return api_1.createDevServerConfigProviderProxy; } }); -var api_2 = require("./lib/features/jest/api"); -Object.defineProperty(exports, "createJestConfig", { enumerable: true, get: function () { return api_2.createJestConfig; } }); -var api_3 = require("./lib/features/webpack/api"); -Object.defineProperty(exports, "createWebpackDevConfig", { enumerable: true, get: function () { return api_3.createWebpackDevConfig; } }); -Object.defineProperty(exports, "createWebpackProdConfig", { enumerable: true, get: function () { return api_3.createWebpackProdConfig; } }); -var loaders_1 = require("./lib/loaders"); -Object.defineProperty(exports, "addAfterLoader", { enumerable: true, get: function () { return loaders_1.addAfterLoader; } }); -Object.defineProperty(exports, "addAfterLoaders", { enumerable: true, get: function () { return loaders_1.addAfterLoaders; } }); -Object.defineProperty(exports, "addBeforeLoader", { enumerable: true, get: function () { return loaders_1.addBeforeLoader; } }); -Object.defineProperty(exports, "addBeforeLoaders", { enumerable: true, get: function () { return loaders_1.addBeforeLoaders; } }); -Object.defineProperty(exports, "getLoader", { enumerable: true, get: function () { return loaders_1.getLoader; } }); -Object.defineProperty(exports, "getLoaders", { enumerable: true, get: function () { return loaders_1.getLoaders; } }); -Object.defineProperty(exports, "loaderByName", { enumerable: true, get: function () { return loaders_1.loaderByName; } }); -Object.defineProperty(exports, "removeLoaders", { enumerable: true, get: function () { return loaders_1.removeLoaders; } }); -var plugin_utils_1 = require("./lib/plugin-utils"); -Object.defineProperty(exports, "gitHubIssueUrl", { enumerable: true, get: function () { return plugin_utils_1.gitHubIssueUrl; } }); -Object.defineProperty(exports, "throwUnexpectedConfigError", { enumerable: true, get: function () { return plugin_utils_1.throwUnexpectedConfigError; } }); -var user_config_utils_1 = require("./lib/user-config-utils"); -Object.defineProperty(exports, "when", { enumerable: true, get: function () { return user_config_utils_1.when; } }); -Object.defineProperty(exports, "whenDev", { enumerable: true, get: function () { return user_config_utils_1.whenDev; } }); -Object.defineProperty(exports, "whenProd", { enumerable: true, get: function () { return user_config_utils_1.whenProd; } }); -Object.defineProperty(exports, "whenTest", { enumerable: true, get: function () { return user_config_utils_1.whenTest; } }); -var webpack_plugins_1 = require("./lib/webpack-plugins"); -Object.defineProperty(exports, "addPlugins", { enumerable: true, get: function () { return webpack_plugins_1.addPlugins; } }); -Object.defineProperty(exports, "getPlugin", { enumerable: true, get: function () { return webpack_plugins_1.getPlugin; } }); -Object.defineProperty(exports, "pluginByName", { enumerable: true, get: function () { return webpack_plugins_1.pluginByName; } }); -Object.defineProperty(exports, "removePlugins", { enumerable: true, get: function () { return webpack_plugins_1.removePlugins; } }); diff --git a/dist/lib/args.d.ts b/dist/lib/args.d.ts deleted file mode 100644 index d4224b54..00000000 --- a/dist/lib/args.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { CliArgs } from '../types/args'; -export declare function getArgs(): CliArgs; -export declare function setArgs(values?: CliArgs): void; -export declare function findArgsFromCli(): void; diff --git a/dist/lib/args.js b/dist/lib/args.js deleted file mode 100644 index 47bf600a..00000000 --- a/dist/lib/args.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.findArgsFromCli = exports.setArgs = exports.getArgs = void 0; -var args = { - verbose: { - arg: '--verbose', - value: false, - }, - config: { - arg: '--config', - value: true, - }, -}; -var processedArgs = {}; -function getArgs() { - return processedArgs; -} -exports.getArgs = getArgs; -function setArgs(values) { - processedArgs = __assign(__assign({}, processedArgs), values); -} -exports.setArgs = setArgs; -function findArgsFromCli() { - var processed = {}; - var i = 0; - while (i < process.argv.length) { - var arg = process.argv[i]; - for (var a in args) { - if (arg === args[a].arg) { - processed[a] = args[a].value ? process.argv[i + 1] : true; - i++; - } - } - i++; - } - setArgs(processed); -} -exports.findArgsFromCli = findArgsFromCli; diff --git a/dist/lib/asset-modules.d.ts b/dist/lib/asset-modules.d.ts deleted file mode 100644 index dbde6070..00000000 --- a/dist/lib/asset-modules.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { RuleSetRule, Configuration as WebpackConfig } from 'webpack'; -import type { AssetModule, AssetModuleMatcher, AssetModuleType } from '../types/asset-modules'; -export declare function assetModuleByName(assetModuleName: AssetModuleType): (rule: RuleSetRule) => boolean; -export declare function getAssetModule(webpackConfig: WebpackConfig, matcher: AssetModuleMatcher): { - isFound: boolean; - match: AssetModule | undefined; -}; -export declare function getAssetModules(webpackConfig: WebpackConfig, matcher: AssetModuleMatcher): { - hasFoundAny: boolean; - matches: AssetModule[]; -}; -export declare function removeAssetModules(webpackConfig: WebpackConfig, matcher: AssetModuleMatcher): { - rules: (RuleSetRule | "...")[] | undefined; - removedCount: number; -}; -export declare const addBeforeAssetModule: (webpackConfig: WebpackConfig, matcher: AssetModuleMatcher, newAssetModule: RuleSetRule) => { - isAdded: boolean; -}; -export declare const addAfterAssetModule: (webpackConfig: WebpackConfig, matcher: AssetModuleMatcher, newAssetModule: RuleSetRule) => { - isAdded: boolean; -}; -export declare const addBeforeAssetModules: (webpackConfig: WebpackConfig, matcher: AssetModuleMatcher, newAssetModule: RuleSetRule) => { - isAdded: boolean; - addedCount: number; -}; -export declare const addAfterAssetModules: (webpackConfig: WebpackConfig, matcher: AssetModuleMatcher, newAssetModule: RuleSetRule) => { - isAdded: boolean; - addedCount: number; -}; diff --git a/dist/lib/asset-modules.js b/dist/lib/asset-modules.js deleted file mode 100644 index f5beeddc..00000000 --- a/dist/lib/asset-modules.js +++ /dev/null @@ -1,86 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.addAfterAssetModules = exports.addBeforeAssetModules = exports.addAfterAssetModule = exports.addBeforeAssetModule = exports.removeAssetModules = exports.getAssetModules = exports.getAssetModule = exports.assetModuleByName = void 0; -function assetModuleByName(assetModuleName) { - return function (rule) { return rule.type === assetModuleName; }; -} -exports.assetModuleByName = assetModuleByName; -var toMatchingAssetModule = function (rule, index) { return ({ - rule: rule, - index: index, -}); }; -function getAssetModule(webpackConfig, matcher) { - var _a, _b; - var matchingAssetModule; - (_b = (_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.some(function (rule, index) { - if (matcher(rule)) { - matchingAssetModule = toMatchingAssetModule(rule, index); - } - return matchingAssetModule !== undefined; - }); - return { - isFound: matchingAssetModule !== undefined, - match: matchingAssetModule, - }; -} -exports.getAssetModule = getAssetModule; -function getAssetModules(webpackConfig, matcher) { - var _a, _b; - var matchingAssetModules = []; - (_b = (_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach(function (rule, index) { - if (matcher(rule)) { - matchingAssetModules.push(toMatchingAssetModule(rule, index)); - } - }); - return { - hasFoundAny: matchingAssetModules.length !== 0, - matches: matchingAssetModules, - }; -} -exports.getAssetModules = getAssetModules; -function removeAssetModules(webpackConfig, matcher) { - var _a, _b, _c; - var toRemove = []; - (_b = (_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach(function (rule, index) { - if (matcher(rule)) { - toRemove.push(index); - } - }); - toRemove.forEach(function (index) { - var _a, _b; - (_b = (_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.splice(index, 1); - }); - return { - rules: (_c = webpackConfig.module) === null || _c === void 0 ? void 0 : _c.rules, - removedCount: toRemove.length, - }; -} -exports.removeAssetModules = removeAssetModules; -function addAssetModule(webpackConfig, matcher, newAssetModule, positionAdapter) { - var _a, _b; - var match = getAssetModule(webpackConfig, matcher).match; - if (match !== undefined) { - (_b = (_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.splice(positionAdapter(match.index), 0, newAssetModule); - return { isAdded: true }; - } - return { isAdded: false }; -} -var addBeforeAssetModule = function (webpackConfig, matcher, newAssetModule) { return addAssetModule(webpackConfig, matcher, newAssetModule, function (x) { return x; }); }; -exports.addBeforeAssetModule = addBeforeAssetModule; -var addAfterAssetModule = function (webpackConfig, matcher, newAssetModule) { return addAssetModule(webpackConfig, matcher, newAssetModule, function (x) { return x + 1; }); }; -exports.addAfterAssetModule = addAfterAssetModule; -function addAssetModules(webpackConfig, matcher, newLoader, positionAdapter) { - var matches = getAssetModules(webpackConfig, matcher).matches; - if (matches.length !== 0) { - matches.forEach(function (match) { - var _a, _b; - (_b = (_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.splice(positionAdapter(match.index), 0, newLoader); - }); - return { isAdded: true, addedCount: matches.length }; - } - return { isAdded: false, addedCount: 0 }; -} -var addBeforeAssetModules = function (webpackConfig, matcher, newAssetModule) { return addAssetModules(webpackConfig, matcher, newAssetModule, function (x) { return x; }); }; -exports.addBeforeAssetModules = addBeforeAssetModules; -var addAfterAssetModules = function (webpackConfig, matcher, newAssetModule) { return addAssetModules(webpackConfig, matcher, newAssetModule, function (x) { return x + 1; }); }; -exports.addAfterAssetModules = addAfterAssetModules; diff --git a/dist/lib/config.d.ts b/dist/lib/config.d.ts deleted file mode 100644 index f31ecd3e..00000000 --- a/dist/lib/config.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { CracoConfig } from '../types/config'; -import type { BaseContext } from '../types/context'; -export declare function processCracoConfig(cracoConfig: CracoConfig, context: BaseContext): CracoConfig; -export declare function loadCracoConfig(context: BaseContext): CracoConfig; -export declare function loadCracoConfigAsync(context: BaseContext): Promise; diff --git a/dist/lib/config.js b/dist/lib/config.js deleted file mode 100644 index e40ef6c0..00000000 --- a/dist/lib/config.js +++ /dev/null @@ -1,156 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.loadCracoConfigAsync = exports.loadCracoConfig = exports.processCracoConfig = void 0; -var cosmiconfig_1 = require("cosmiconfig"); -var cosmiconfig_typescript_loader_1 = __importDefault(require("cosmiconfig-typescript-loader")); -var path_1 = __importDefault(require("path")); -var args_1 = require("./args"); -var plugins_1 = require("./features/plugins"); -var logger_1 = require("./logger"); -var paths_1 = require("./paths"); -var utils_1 = require("./utils"); -var DEFAULT_CONFIG = { - reactScriptsVersion: 'react-scripts', - style: { - postcss: { - mode: 'extends', - }, - }, - eslint: { - mode: 'extends', - }, - jest: { - babel: { - addPresets: true, - addPlugins: true, - }, - }, -}; -var moduleName = 'craco'; -var explorer = (0, cosmiconfig_1.cosmiconfigSync)(moduleName, { - searchPlaces: [ - 'package.json', - "".concat(moduleName, ".config.ts"), - "".concat(moduleName, ".config.js"), - "".concat(moduleName, ".config.cjs"), - ".".concat(moduleName, "rc.ts"), - ".".concat(moduleName, "rc.js"), - ".".concat(moduleName, "rc"), - ], - loaders: { - '.ts': (0, cosmiconfig_typescript_loader_1.default)(), - }, -}); -function ensureConfigSanity(cracoConfig) { - if (cracoConfig.plugins && (0, utils_1.isArray)(cracoConfig.plugins)) { - cracoConfig.plugins.forEach(function (x, index) { - if (!x.plugin) { - throw new Error("craco: Malformed plugin at index: ".concat(index, " of 'plugins'.")); - } - }); - } -} -function processCracoConfig(cracoConfig, context) { - var resultingCracoConfig = (0, utils_1.deepMergeWithArray)({}, DEFAULT_CONFIG, cracoConfig); - ensureConfigSanity(resultingCracoConfig); - return (0, plugins_1.applyCracoConfigPlugins)(resultingCracoConfig, context); -} -exports.processCracoConfig = processCracoConfig; -function getConfigPath() { - var args = (0, args_1.getArgs)(); - if (args.config && (0, utils_1.isString)(args.config)) { - return path_1.default.resolve(paths_1.projectRoot, args.config); - } - else { - var packageJsonPath = path_1.default.join(paths_1.projectRoot, 'package.json'); - var packageJson = require(packageJsonPath); - if (packageJson.cracoConfig && (0, utils_1.isString)(packageJson.cracoConfig)) { - // take it as the path to the config file if it's path-like, otherwise assume it contains the config content below - return path_1.default.resolve(paths_1.projectRoot, packageJson.cracoConfig); - } - else { - var result = explorer.search(paths_1.projectRoot); - if (result === null) { - throw new Error('craco: Config file not found. check if file exists at root (craco.config.ts, craco.config.js, .cracorc.js, .cracorc.json, .cracorc.yaml, .cracorc)'); - } - return result.filepath; - } - } -} -function getConfigAsObject(context) { - var configFilePath = getConfigPath(); - (0, logger_1.log)('Config file path resolved to: ', configFilePath); - var result = explorer.load(configFilePath); - var configAsObject = (0, utils_1.isFunction)(result === null || result === void 0 ? void 0 : result.config) - ? result === null || result === void 0 ? void 0 : result.config(context) - : result === null || result === void 0 ? void 0 : result.config; - if (!configAsObject) { - throw new Error("craco: Config function didn't return a config object."); - } - return configAsObject; -} -function loadCracoConfig(context) { - var configAsObject = getConfigAsObject(context); - if (configAsObject instanceof Promise) { - throw new Error('craco: Config function returned a promise. Use `loadCracoConfigAsync` instead of `loadCracoConfig`.'); - } - return processCracoConfig(configAsObject, context); -} -exports.loadCracoConfig = loadCracoConfig; -// The "build", "start", and "test" scripts use this to wait for any promises to resolve before they run. -function loadCracoConfigAsync(context) { - return __awaiter(this, void 0, void 0, function () { - var configAsObject; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, getConfigAsObject(context)]; - case 1: - configAsObject = _a.sent(); - if (!configAsObject) { - throw new Error("craco: Async config didn't return a config object."); - } - return [2 /*return*/, processCracoConfig(configAsObject, context)]; - } - }); - }); -} -exports.loadCracoConfigAsync = loadCracoConfigAsync; diff --git a/dist/lib/cra.d.ts b/dist/lib/cra.d.ts deleted file mode 100644 index 59d77018..00000000 --- a/dist/lib/cra.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoConfig } from '../types/config'; -export declare function getReactScriptVersion(cracoConfig: CracoConfig): { - version: any; - isSupported: boolean; -}; -export declare function getCraPaths(cracoConfig: CracoConfig): any; -export declare function loadWebpackDevConfig(cracoConfig: CracoConfig): WebpackConfig; -export declare function overrideWebpackDevConfig(cracoConfig: CracoConfig, newConfig: WebpackConfig): void; -export declare function loadWebpackProdConfig(cracoConfig: CracoConfig): WebpackConfig; -export declare function overrideWebpackProdConfig(cracoConfig: CracoConfig, newConfig: WebpackConfig): void; -export declare function loadDevServerConfigProvider(cracoConfig: CracoConfig): any; -export declare function overrideDevServerConfigProvider(cracoConfig: CracoConfig, configProvider: any): void; -export declare function loadDevServerUtils(): any; -export declare function overrideDevServerUtils(newUtils: any): void; -export declare function loadJestConfigProvider(cracoConfig: CracoConfig): any; -export declare function overrideJestConfigProvider(cracoConfig: CracoConfig, configProvider: any): void; -/************ Scripts *******************/ -export declare function start(cracoConfig: CracoConfig): void; -export declare function build(cracoConfig: CracoConfig): void; -export declare function test(cracoConfig: CracoConfig): void; diff --git a/dist/lib/cra.js b/dist/lib/cra.js deleted file mode 100644 index 01df8843..00000000 --- a/dist/lib/cra.js +++ /dev/null @@ -1,200 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.test = exports.build = exports.start = exports.overrideJestConfigProvider = exports.loadJestConfigProvider = exports.overrideDevServerUtils = exports.loadDevServerUtils = exports.overrideDevServerConfigProvider = exports.loadDevServerConfigProvider = exports.overrideWebpackProdConfig = exports.loadWebpackProdConfig = exports.overrideWebpackDevConfig = exports.loadWebpackDevConfig = exports.getCraPaths = exports.getReactScriptVersion = void 0; -var path_1 = __importDefault(require("path")); -var semver_1 = __importDefault(require("semver")); -var logger_1 = require("./logger"); -var paths_1 = require("./paths"); -var envLoaded = false; -var CRA_LATEST_SUPPORTED_MAJOR_VERSION = '5.0.0'; -/************ Common ************/ -// TODO here -function resolveConfigFilePath(cracoConfig, fileName) { - if (!envLoaded) { - // Environment variables must be loaded before the CRA paths, otherwise they will not be applied. - require(resolveConfigFilePathInner(cracoConfig, 'env.js')); - envLoaded = true; - } - return resolveConfigFilePathInner(cracoConfig, fileName); -} -function resolveConfigFilePathInner(cracoConfig, fileName) { - var _a; - return require.resolve(path_1.default.join((_a = cracoConfig.reactScriptsVersion) !== null && _a !== void 0 ? _a : 'react-scripts', 'config', fileName), { paths: [paths_1.projectRoot] }); -} -function resolveScriptsFilePath(cracoConfig, fileName) { - var _a; - return require.resolve(path_1.default.join((_a = cracoConfig.reactScriptsVersion) !== null && _a !== void 0 ? _a : 'react-scripts', 'scripts', fileName), { paths: [paths_1.projectRoot] }); -} -function resolveReactDevUtilsPath(fileName) { - return require.resolve(path_1.default.join('react-dev-utils', fileName), { - paths: [paths_1.projectRoot], - }); -} -function overrideModule(modulePath, newModule) { - if (!require.cache[modulePath]) { - throw new Error("Module not found: ".concat(modulePath)); - } - require.cache[modulePath].exports = newModule; - (0, logger_1.log)("Overrided require cache for module: ".concat(modulePath)); -} -function resolvePackageJson(cracoConfig) { - var _a; - return require.resolve(path_1.default.join((_a = cracoConfig.reactScriptsVersion) !== null && _a !== void 0 ? _a : 'react-scripts', 'package.json'), { paths: [paths_1.projectRoot] }); -} -function getReactScriptVersion(cracoConfig) { - var reactScriptPackageJsonPath = resolvePackageJson(cracoConfig); - var version = require(reactScriptPackageJsonPath).version; - return { - version: version, - isSupported: semver_1.default.gte(version, CRA_LATEST_SUPPORTED_MAJOR_VERSION), - }; -} -exports.getReactScriptVersion = getReactScriptVersion; -/************ Paths ************/ -var _resolvedCraPaths = null; -function getCraPaths(cracoConfig) { - if (!_resolvedCraPaths) { - _resolvedCraPaths = require(resolveConfigFilePath(cracoConfig, 'paths.js')); - } - return _resolvedCraPaths; -} -exports.getCraPaths = getCraPaths; -/************ Webpack Dev Config ************/ -function getWebpackDevConfigPath(cracoConfig) { - try { - return { - filepath: resolveConfigFilePath(cracoConfig, 'webpack.config.js'), - isLegacy: false, - }; - } - catch (e) { - return { - filepath: resolveConfigFilePath(cracoConfig, 'webpack.config.dev.js'), - isLegacy: true, - }; - } -} -function loadWebpackDevConfig(cracoConfig) { - var result = getWebpackDevConfigPath(cracoConfig); - (0, logger_1.log)('Found Webpack dev config at: ', result.filepath); - if (result.isLegacy) { - return require(result.filepath); - } - return require(result.filepath)('development'); -} -exports.loadWebpackDevConfig = loadWebpackDevConfig; -function overrideWebpackDevConfig(cracoConfig, newConfig) { - var result = getWebpackDevConfigPath(cracoConfig); - if (result.isLegacy) { - overrideModule(result.filepath, newConfig); - } - else { - overrideModule(result.filepath, function () { return newConfig; }); - } - (0, logger_1.log)('Overrided Webpack dev config.'); -} -exports.overrideWebpackDevConfig = overrideWebpackDevConfig; -/************ Webpack Prod Config ************/ -function getWebpackProdConfigPath(cracoConfig) { - try { - return { - filepath: resolveConfigFilePath(cracoConfig, 'webpack.config.js'), - isLegacy: false, - }; - } - catch (e) { - return { - filepath: resolveConfigFilePath(cracoConfig, 'webpack.config.prod.js'), - isLegacy: true, - }; - } -} -function loadWebpackProdConfig(cracoConfig) { - var result = getWebpackProdConfigPath(cracoConfig); - (0, logger_1.log)('Found Webpack prod config at: ', result.filepath); - if (result.isLegacy) { - return require(result.filepath); - } - return require(result.filepath)('production'); -} -exports.loadWebpackProdConfig = loadWebpackProdConfig; -function overrideWebpackProdConfig(cracoConfig, newConfig) { - var result = getWebpackProdConfigPath(cracoConfig); - if (result.isLegacy) { - overrideModule(result.filepath, newConfig); - } - else { - overrideModule(result.filepath, function () { return newConfig; }); - } - (0, logger_1.log)('Overrided Webpack prod config.'); -} -exports.overrideWebpackProdConfig = overrideWebpackProdConfig; -/************ Dev Server Config ************/ -function getDevServerConfigPath(cracoConfig) { - return resolveConfigFilePath(cracoConfig, 'webpackDevServer.config.js'); -} -function getDevServerUtilsPath() { - return resolveReactDevUtilsPath('WebpackDevServerUtils.js'); -} -function loadDevServerConfigProvider(cracoConfig) { - var filepath = getDevServerConfigPath(cracoConfig); - (0, logger_1.log)('Found dev server config at: ', filepath); - return require(filepath); -} -exports.loadDevServerConfigProvider = loadDevServerConfigProvider; -function overrideDevServerConfigProvider(cracoConfig, configProvider) { - var filepath = getDevServerConfigPath(cracoConfig); - overrideModule(filepath, configProvider); - (0, logger_1.log)('Overrided dev server config provider.'); -} -exports.overrideDevServerConfigProvider = overrideDevServerConfigProvider; -function loadDevServerUtils() { - var filepath = getDevServerUtilsPath(); - (0, logger_1.log)('Found dev server utils at: ', filepath); - return require(filepath); -} -exports.loadDevServerUtils = loadDevServerUtils; -function overrideDevServerUtils(newUtils) { - var filepath = getDevServerUtilsPath(); - overrideModule(filepath, newUtils); - (0, logger_1.log)('Overrided dev server utils.'); -} -exports.overrideDevServerUtils = overrideDevServerUtils; -/************ Jest Config ************/ -function getCreateJestConfigPath(cracoConfig) { - return resolveScriptsFilePath(cracoConfig, 'utils/createJestConfig.js'); -} -function loadJestConfigProvider(cracoConfig) { - var filepath = getCreateJestConfigPath(cracoConfig); - (0, logger_1.log)('Found jest config at: ', filepath); - return require(filepath); -} -exports.loadJestConfigProvider = loadJestConfigProvider; -function overrideJestConfigProvider(cracoConfig, configProvider) { - var filepath = getCreateJestConfigPath(cracoConfig); - overrideModule(filepath, configProvider); - (0, logger_1.log)('Overrided Jest config provider.'); -} -exports.overrideJestConfigProvider = overrideJestConfigProvider; -/************ Scripts *******************/ -function start(cracoConfig) { - var filepath = resolveScriptsFilePath(cracoConfig, 'start.js'); - (0, logger_1.log)('Starting CRA at: ', filepath); - require(filepath); -} -exports.start = start; -function build(cracoConfig) { - var filepath = resolveScriptsFilePath(cracoConfig, 'build.js'); - (0, logger_1.log)('Building CRA at: ', filepath); - require(filepath); -} -exports.build = build; -function test(cracoConfig) { - var filepath = resolveScriptsFilePath(cracoConfig, 'test.js'); - (0, logger_1.log)('Testing CRA at: ', filepath); - require(filepath); -} -exports.test = test; diff --git a/dist/lib/features/dev-server/api.d.ts b/dist/lib/features/dev-server/api.d.ts deleted file mode 100644 index be0519b6..00000000 --- a/dist/lib/features/dev-server/api.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { CliArgs } from '../../../types/args'; -import type { CracoConfig } from '../../../types/config'; -import type { DevServerContext } from '../../../types/context'; -export declare function createDevServerConfigProviderProxy(callerCracoConfig: CracoConfig, callerContext: DevServerContext, options: CliArgs): (proxy: any, allowedHost: string) => any; diff --git a/dist/lib/features/dev-server/api.js b/dist/lib/features/dev-server/api.js deleted file mode 100644 index 44afe3ea..00000000 --- a/dist/lib/features/dev-server/api.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createDevServerConfigProviderProxy = void 0; -var args_1 = require("../../args"); -var config_1 = require("../../config"); -var cra_1 = require("../../cra"); -var utils_1 = require("../../utils"); -var create_config_provider_proxy_1 = require("./create-config-provider-proxy"); -function createDevServerConfigProviderProxy(callerCracoConfig, callerContext, options) { - if (!callerCracoConfig) { - throw new Error("craco: 'cracoConfig' is required."); - } - if ((0, utils_1.isFunction)(callerCracoConfig)) { - throw new Error("craco: 'cracoConfig' should be an object."); - } - if (!process.env.NODE_ENV) { - process.env.NODE_ENV = 'development'; - } - (0, args_1.setArgs)(options); - var context = __assign({ env: process.env.NODE_ENV }, callerContext); - var cracoConfig = (0, config_1.processCracoConfig)(callerCracoConfig, context); - context.paths = (0, cra_1.getCraPaths)(cracoConfig); - var proxy = (0, create_config_provider_proxy_1.createConfigProviderProxy)(cracoConfig, context); - return proxy; -} -exports.createDevServerConfigProviderProxy = createDevServerConfigProviderProxy; diff --git a/dist/lib/features/dev-server/create-config-provider-proxy.d.ts b/dist/lib/features/dev-server/create-config-provider-proxy.d.ts deleted file mode 100644 index 6853a703..00000000 --- a/dist/lib/features/dev-server/create-config-provider-proxy.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -import type { DevServerContext } from '../../../types/context'; -export declare function createConfigProviderProxy(cracoConfig: CracoConfig, context: DevServerContext): (proxy: any, allowedHost: string) => any; diff --git a/dist/lib/features/dev-server/create-config-provider-proxy.js b/dist/lib/features/dev-server/create-config-provider-proxy.js deleted file mode 100644 index a7c7696a..00000000 --- a/dist/lib/features/dev-server/create-config-provider-proxy.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createConfigProviderProxy = void 0; -var webpack_merge_1 = __importDefault(require("webpack-merge")); -var cra_1 = require("../../cra"); -var logger_1 = require("../../logger"); -var utils_1 = require("../../utils"); -var plugins_1 = require("../plugins"); -function createProxy(cracoConfig, craDevServerConfigProvider, context) { - var proxy = function (proxy, allowedHost) { - var devServerConfig = craDevServerConfigProvider(proxy, allowedHost); - if ((0, utils_1.isFunction)(cracoConfig.devServer)) { - devServerConfig = cracoConfig.devServer(devServerConfig, __assign(__assign({}, context), { proxy: proxy, allowedHost: allowedHost })); - if (!devServerConfig) { - throw new Error("craco: 'devServer' function didn't return a config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - devServerConfig = (0, webpack_merge_1.default)(devServerConfig, cracoConfig.devServer || {}); - } - devServerConfig = (0, plugins_1.applyDevServerConfigPlugins)(cracoConfig, devServerConfig, __assign(__assign({}, context), { proxy: proxy, allowedHost: allowedHost })); - (0, logger_1.log)('Merged DevServer config.'); - return devServerConfig; - }; - return proxy; -} -function createConfigProviderProxy(cracoConfig, context) { - var craDevServerConfigProvider = (0, cra_1.loadDevServerConfigProvider)(cracoConfig); - var proxy = createProxy(cracoConfig, craDevServerConfigProvider, context); - return proxy; -} -exports.createConfigProviderProxy = createConfigProviderProxy; diff --git a/dist/lib/features/dev-server/override-utils.d.ts b/dist/lib/features/dev-server/override-utils.d.ts deleted file mode 100644 index 5712a996..00000000 --- a/dist/lib/features/dev-server/override-utils.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { CracoConfig } from '../../../types/config'; -declare function overrideUtils(cracoConfig: CracoConfig): void; -export { overrideUtils as overrideDevServerUtils }; diff --git a/dist/lib/features/dev-server/override-utils.js b/dist/lib/features/dev-server/override-utils.js deleted file mode 100644 index df8d62a0..00000000 --- a/dist/lib/features/dev-server/override-utils.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideDevServerUtils = void 0; -var cra_1 = require("../../cra"); -var logger_1 = require("../../logger"); -function overrideWebpackCompilerToDisableTypeScriptTypeChecking(craDevServersUtils) { - if (craDevServersUtils.createCompiler) { - var craCreateCompiler_1 = craDevServersUtils.createCompiler; - craDevServersUtils.createCompiler = function (args) { - var newArgs = __assign(__assign({}, args), { useTypeScript: false }); - return craCreateCompiler_1(newArgs); - }; - (0, logger_1.log)('Overrided Webpack compiler to disable TypeScript type checking.'); - } - return craDevServersUtils; -} -function overrideUtils(cracoConfig) { - if (cracoConfig.typescript) { - var enableTypeChecking = cracoConfig.typescript.enableTypeChecking; - if (enableTypeChecking === false) { - var craDevServersUtils = (0, cra_1.loadDevServerUtils)(); - var resultingDevServersUtils = overrideWebpackCompilerToDisableTypeScriptTypeChecking(craDevServersUtils); - (0, cra_1.overrideDevServerUtils)(resultingDevServersUtils); - } - } -} -exports.overrideDevServerUtils = overrideUtils; diff --git a/dist/lib/features/dev-server/override.d.ts b/dist/lib/features/dev-server/override.d.ts deleted file mode 100644 index 73880253..00000000 --- a/dist/lib/features/dev-server/override.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -import type { DevServerContext } from '../../../types/context'; -export declare function overrideDevServer(cracoConfig: CracoConfig, context: DevServerContext): void; diff --git a/dist/lib/features/dev-server/override.js b/dist/lib/features/dev-server/override.js deleted file mode 100644 index 63851e79..00000000 --- a/dist/lib/features/dev-server/override.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideDevServer = void 0; -var cra_1 = require("../../cra"); -var create_config_provider_proxy_1 = require("./create-config-provider-proxy"); -var override_utils_1 = require("./override-utils"); -var set_environment_variables_1 = require("./set-environment-variables"); -function overrideDevServer(cracoConfig, context) { - (0, override_utils_1.overrideDevServerUtils)(cracoConfig); - (0, set_environment_variables_1.setEnvironmentVariables)(cracoConfig); - var proxy = (0, create_config_provider_proxy_1.createConfigProviderProxy)(cracoConfig, context); - (0, cra_1.overrideDevServerConfigProvider)(cracoConfig, proxy); -} -exports.overrideDevServer = overrideDevServer; diff --git a/dist/lib/features/dev-server/set-environment-variables.d.ts b/dist/lib/features/dev-server/set-environment-variables.d.ts deleted file mode 100644 index 17a54cd0..00000000 --- a/dist/lib/features/dev-server/set-environment-variables.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -export declare function setEnvironmentVariables(cracoConfig: CracoConfig): void; diff --git a/dist/lib/features/dev-server/set-environment-variables.js b/dist/lib/features/dev-server/set-environment-variables.js deleted file mode 100644 index f3b5abe3..00000000 --- a/dist/lib/features/dev-server/set-environment-variables.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setEnvironmentVariables = void 0; -var utils_1 = require("../../utils"); -function setEnvironmentVariable(envProperty, value) { - if (!(0, utils_1.isString)(value)) { - process.env[envProperty] = value.toString(); - } - else { - process.env[envProperty] = value; - } -} -function setEnvironmentVariables(cracoConfig) { - if (cracoConfig.devServer) { - var devServer = void 0; - if ((0, utils_1.isFunction)(cracoConfig.devServer)) { - devServer = cracoConfig.devServer({}, {}); - } - else { - devServer = cracoConfig.devServer; - } - var open_1 = devServer.open, https = devServer.https, host = devServer.host, port = devServer.port; - if (open_1 === false) { - setEnvironmentVariable('BROWSER', 'none'); - } - if (https) { - setEnvironmentVariable('HTTPS', 'true'); - } - if (host) { - setEnvironmentVariable('HOST', host); - } - if (port) { - setEnvironmentVariable('PORT', port); - } - } -} -exports.setEnvironmentVariables = setEnvironmentVariables; diff --git a/dist/lib/features/jest/api.d.ts b/dist/lib/features/jest/api.d.ts deleted file mode 100644 index f566f335..00000000 --- a/dist/lib/features/jest/api.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { CliArgs } from '../../../types/args'; -import type { CracoConfig } from '../../../types/config'; -import type { JestContext } from '../../../types/context'; -export declare function createJestConfig(callerCracoConfig: CracoConfig, callerContext?: JestContext, options?: CliArgs): any; diff --git a/dist/lib/features/jest/api.js b/dist/lib/features/jest/api.js deleted file mode 100644 index 7b0621e5..00000000 --- a/dist/lib/features/jest/api.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createJestConfig = void 0; -var args_1 = require("../../args"); -var config_1 = require("../../config"); -var cra_1 = require("../../cra"); -var utils_1 = require("../../utils"); -var merge_jest_config_1 = require("./merge-jest-config"); -function createJestConfig(callerCracoConfig, callerContext, options) { - if (callerContext === void 0) { callerContext = {}; } - if (options === void 0) { options = {}; } - if (!callerCracoConfig) { - throw new Error("craco: 'cracoConfig' is required."); - } - if ((0, utils_1.isFunction)(callerCracoConfig)) { - throw new Error("craco: 'cracoConfig' should be an object."); - } - if (!process.env.NODE_ENV) { - process.env.NODE_ENV = 'development'; - } - (0, args_1.setArgs)(options); - var context = __assign({ env: process.env.NODE_ENV }, callerContext); - var cracoConfig = (0, config_1.processCracoConfig)(callerCracoConfig, context); - context.paths = (0, cra_1.getCraPaths)(cracoConfig); - var craJestConfigProvider = (0, cra_1.loadJestConfigProvider)(cracoConfig); - return (0, merge_jest_config_1.mergeJestConfig)(cracoConfig, craJestConfigProvider, context); -} -exports.createJestConfig = createJestConfig; diff --git a/dist/lib/features/jest/create-jest-babel-transform.d.ts b/dist/lib/features/jest/create-jest-babel-transform.d.ts deleted file mode 100644 index 450b2847..00000000 --- a/dist/lib/features/jest/create-jest-babel-transform.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -export declare function createJestBabelTransform(cracoConfig?: CracoConfig): any; diff --git a/dist/lib/features/jest/create-jest-babel-transform.js b/dist/lib/features/jest/create-jest-babel-transform.js deleted file mode 100644 index 5f9050fd..00000000 --- a/dist/lib/features/jest/create-jest-babel-transform.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createJestBabelTransform = void 0; -var babel_jest_1 = __importDefault(require("babel-jest")); -var config_1 = require("../../config"); -var utils_1 = require("../../utils"); -/** - * To check if support jsx-runtime - * Copy from https://github.com/facebook/create-react-app/blob/2b1161b34641bb4d2f269661cd636bbcd4888406/packages/react-scripts/config/jest/babelTransform.js#L12 - */ -var hasJsxRuntime = (function () { - if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') { - return false; - } - try { - require.resolve('react/jsx-runtime'); - return true; - } - catch (e) { - return false; - } -})(); -// TODO shouldn't have to type this as any, maybe dependencies are messed up? -function createJestBabelTransform(cracoConfig) { - var _a, _b, _c; - if (!cracoConfig) { - var context = { env: process.env.NODE_ENV }; - cracoConfig = (0, config_1.loadCracoConfig)(context); - } - var craBabelTransformer = { - presets: [ - [ - 'babel-preset-react-app', - { - runtime: hasJsxRuntime ? 'automatic' : 'classic', - }, - ], - ], - babelrc: false, - configFile: false, - }; - if (cracoConfig) { - var _d = (_b = (_a = cracoConfig.jest) === null || _a === void 0 ? void 0 : _a.babel) !== null && _b !== void 0 ? _b : {}, addPresets = _d.addPresets, addPlugins = _d.addPlugins; - if (cracoConfig.babel) { - if (addPresets) { - var presets = cracoConfig.babel.presets; - if ((0, utils_1.isArray)(presets)) { - craBabelTransformer.presets = - (_c = craBabelTransformer.presets) === null || _c === void 0 ? void 0 : _c.concat(presets); - } - } - if (addPlugins) { - var plugins = cracoConfig.babel.plugins; - if ((0, utils_1.isArray)(plugins)) { - craBabelTransformer.plugins = plugins; - } - } - } - } - return babel_jest_1.default.createTransformer - ? babel_jest_1.default.createTransformer(craBabelTransformer) - : undefined; -} -exports.createJestBabelTransform = createJestBabelTransform; diff --git a/dist/lib/features/jest/jest-babel-transform.d.ts b/dist/lib/features/jest/jest-babel-transform.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/dist/lib/features/jest/jest-babel-transform.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/dist/lib/features/jest/jest-babel-transform.js b/dist/lib/features/jest/jest-babel-transform.js deleted file mode 100644 index 62a57131..00000000 --- a/dist/lib/features/jest/jest-babel-transform.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var config_1 = require("../../config"); -var create_jest_babel_transform_1 = require("./create-jest-babel-transform"); -var jestBabelTransform; -// cracoConfig is only available inside the transform, but the transform needs to include whatever options cracoConfig -// specifies. So, the first time this transform is run, it generates a new transform -- using cracoConfig -- and -// uses that to process files. -module.exports = __assign(__assign({}, (0, create_jest_babel_transform_1.createJestBabelTransform)()), { processAsync: function (src, filename, transformOptions) { - return __awaiter(this, void 0, void 0, function () { - var context, cracoConfig; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!!jestBabelTransform) return [3 /*break*/, 2]; - context = { env: process.env.NODE_ENV }; - return [4 /*yield*/, (0, config_1.loadCracoConfigAsync)(context)]; - case 1: - cracoConfig = _a.sent(); - jestBabelTransform = (0, create_jest_babel_transform_1.createJestBabelTransform)(cracoConfig); - _a.label = 2; - case 2: return [2 /*return*/, jestBabelTransform === null || jestBabelTransform === void 0 ? void 0 : jestBabelTransform.process(src, filename, transformOptions)]; - } - }); - }); - } }); diff --git a/dist/lib/features/jest/merge-jest-config.d.ts b/dist/lib/features/jest/merge-jest-config.d.ts deleted file mode 100644 index 5595f2cd..00000000 --- a/dist/lib/features/jest/merge-jest-config.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -import type { JestContext } from '../../../types/context'; -export declare function mergeJestConfig(cracoConfig: CracoConfig, craJestConfigProvider: any, context: JestContext): any; diff --git a/dist/lib/features/jest/merge-jest-config.js b/dist/lib/features/jest/merge-jest-config.js deleted file mode 100644 index d70a2e38..00000000 --- a/dist/lib/features/jest/merge-jest-config.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.mergeJestConfig = void 0; -var path_1 = __importDefault(require("path")); -var logger_1 = require("../../logger"); -var paths_1 = require("../../paths"); -var utils_1 = require("../../utils"); -var plugins_1 = require("../plugins"); -var BABEL_TRANSFORM_ENTRY_KEY = '^.+\\.(js|jsx|mjs|cjs|ts|tsx)$'; -function overrideBabelTransform(jestConfig, cracoConfig, transformKey) { - // The cracoConfig needs to be available within the jest-babel-transform in order to honor its settings. - // This approach is based on https://github.com/facebook/jest/issues/1468#issuecomment-384825178 - jestConfig.globals = jestConfig.globals || {}; - jestConfig.globals._cracoConfig = cracoConfig; - if (!jestConfig.transform) { - jestConfig.transform = {}; - } - jestConfig.transform[transformKey] = require.resolve('./jest-babel-transform'); - (0, logger_1.log)('Overrided Jest Babel transformer.'); -} -function configureBabel(jestConfig, cracoConfig) { - var _a, _b; - var _c = (_b = (_a = cracoConfig.jest) === null || _a === void 0 ? void 0 : _a.babel) !== null && _b !== void 0 ? _b : {}, addPresets = _c.addPresets, addPlugins = _c.addPlugins; - if (addPresets || addPlugins) { - if (cracoConfig.babel) { - var _d = cracoConfig.babel, presets = _d.presets, plugins = _d.plugins; - if ((0, utils_1.isArray)(presets) || (0, utils_1.isArray)(plugins)) { - if (!jestConfig.transform) { - jestConfig.transform = {}; - } - if (jestConfig.transform[BABEL_TRANSFORM_ENTRY_KEY]) { - overrideBabelTransform(jestConfig, cracoConfig, BABEL_TRANSFORM_ENTRY_KEY); - } - else { - throw new Error("craco: Cannot find Jest transform entry for Babel ".concat(BABEL_TRANSFORM_ENTRY_KEY, ".")); - } - } - } - } -} -function giveTotalControl(jestConfig, configureJest, context) { - if ((0, utils_1.isFunction)(configureJest)) { - jestConfig = configureJest(jestConfig, context); - if (!jestConfig) { - throw new Error("craco: 'jest.configure' function didn't returned a Jest config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - jestConfig = (0, utils_1.deepMergeWithArray)({}, jestConfig, configureJest); - } - (0, logger_1.log)("Merged Jest config with 'jest.configure'."); - return jestConfig; -} -// TODO what is craJestConfigProvider? -function mergeJestConfig(cracoConfig, craJestConfigProvider, context) { - var customResolve = function (relativePath) { - var _a; - return require.resolve(path_1.default.join((_a = cracoConfig.reactScriptsVersion) !== null && _a !== void 0 ? _a : 'react-scripts', relativePath), { paths: [paths_1.projectRoot] }); - }; - var jestConfig = craJestConfigProvider(customResolve, paths_1.projectRoot, false); - if (cracoConfig.jest) { - configureBabel(jestConfig, cracoConfig); - var jestContext = __assign(__assign({}, context), { resolve: customResolve, rootDir: paths_1.projectRoot }); - if (cracoConfig.jest.configure) { - jestConfig = giveTotalControl(jestConfig, cracoConfig.jest.configure, jestContext); - } - jestConfig = (0, plugins_1.applyJestConfigPlugins)(cracoConfig, jestConfig, jestContext); - (0, logger_1.log)('Merged Jest config.'); - } - return jestConfig; -} -exports.mergeJestConfig = mergeJestConfig; diff --git a/dist/lib/features/jest/override.d.ts b/dist/lib/features/jest/override.d.ts deleted file mode 100644 index 2d739a21..00000000 --- a/dist/lib/features/jest/override.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -import type { JestContext } from '../../../types/context'; -export declare function overrideJest(cracoConfig: CracoConfig, context: JestContext): void; diff --git a/dist/lib/features/jest/override.js b/dist/lib/features/jest/override.js deleted file mode 100644 index 23a0f779..00000000 --- a/dist/lib/features/jest/override.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideJest = void 0; -var cra_1 = require("../../cra"); -var logger_1 = require("../../logger"); -var merge_jest_config_1 = require("./merge-jest-config"); -function overrideJest(cracoConfig, context) { - if (cracoConfig.jest) { - var craJestConfigProvider_1 = (0, cra_1.loadJestConfigProvider)(cracoConfig); - var proxy = function () { - return (0, merge_jest_config_1.mergeJestConfig)(cracoConfig, craJestConfigProvider_1, context); - }; - (0, cra_1.overrideJestConfigProvider)(cracoConfig, proxy); - (0, logger_1.log)('Overrided Jest config.'); - } -} -exports.overrideJest = overrideJest; diff --git a/dist/lib/features/plugins.d.ts b/dist/lib/features/plugins.d.ts deleted file mode 100644 index d01742b1..00000000 --- a/dist/lib/features/plugins.d.ts +++ /dev/null @@ -1,138 +0,0 @@ -import type { Config as JestConfig } from '@jest/types'; -import type { Configuration as WebpackConfig } from 'webpack'; -import type { Configuration as DevServerConfig } from 'webpack-dev-server'; -import type { CracoConfig } from '../../types/config'; -import type { BaseContext, DevServerContext, JestContext, WebpackContext } from '../../types/context'; -export declare function applyCracoConfigPlugins(cracoConfig: CracoConfig, context: BaseContext): CracoConfig; -export declare function applyWebpackConfigPlugins(cracoConfig: CracoConfig, webpackConfig: WebpackConfig, context: WebpackContext): WebpackConfig; -export declare function applyDevServerConfigPlugins(cracoConfig: CracoConfig, devServerConfig: DevServerConfig, context: DevServerContext): DevServerConfig; -export declare function applyJestConfigPlugins(cracoConfig: CracoConfig, jestConfig: JestConfig.InitialOptions, context: JestContext): Partial<{ - automock: boolean; - bail: number | boolean; - cache: boolean; - cacheDirectory: string; - ci: boolean; - clearMocks: boolean; - changedFilesWithAncestor: boolean; - changedSince: string; - collectCoverage: boolean; - collectCoverageFrom: string[]; - collectCoverageOnlyFrom: { - [key: string]: boolean; - }; - coverageDirectory: string; - coveragePathIgnorePatterns: string[]; - coverageProvider: "babel" | "v8"; - coverageReporters: JestConfig.CoverageReporters; - coverageThreshold: { - [path: string]: JestConfig.CoverageThresholdValue; - global: JestConfig.CoverageThresholdValue; - }; - dependencyExtractor: string; - detectLeaks: boolean; - detectOpenHandles: boolean; - displayName: string | JestConfig.DisplayName; - expand: boolean; - extensionsToTreatAsEsm: string[]; - fakeTimers: JestConfig.GlobalFakeTimersConfig & ((JestConfig.FakeTimersConfig & { - now?: number | undefined; - }) | JestConfig.LegacyFakeTimersConfig); - filter: string; - findRelatedTests: boolean; - forceCoverageMatch: string[]; - forceExit: boolean; - json: boolean; - globals: JestConfig.ConfigGlobals; - globalSetup: string | null | undefined; - globalTeardown: string | null | undefined; - haste: JestConfig.HasteConfig; - id: string; - injectGlobals: boolean; - reporters: (string | JestConfig.ReporterConfig)[]; - logHeapUsage: boolean; - lastCommit: boolean; - listTests: boolean; - maxConcurrency: number; - maxWorkers: string | number; - moduleDirectories: string[]; - moduleFileExtensions: string[]; - moduleNameMapper: { - [key: string]: string | string[]; - }; - modulePathIgnorePatterns: string[]; - modulePaths: string[]; - noStackTrace: boolean; - notify: boolean; - notifyMode: string; - onlyChanged: boolean; - onlyFailures: boolean; - outputFile: string; - passWithNoTests: boolean; - preset: string | null | undefined; - prettierPath: string | null | undefined; - projects: (string | JestConfig.InitialProjectOptions)[]; - replname: string | null | undefined; - resetMocks: boolean; - resetModules: boolean; - resolver: string | null | undefined; - restoreMocks: boolean; - rootDir: string; - roots: string[]; - runner: string; - runTestsByPath: boolean; - runtime: string; - sandboxInjectedGlobals: string[]; - setupFiles: string[]; - setupFilesAfterEnv: string[]; - silent: boolean; - skipFilter: boolean; - skipNodeResolution: boolean; - slowTestThreshold: number; - snapshotResolver: string; - snapshotSerializers: string[]; - snapshotFormat: { - readonly callToJSON?: boolean | undefined; - readonly escapeRegex?: boolean | undefined; - readonly escapeString?: boolean | undefined; - readonly highlight?: boolean | undefined; - readonly indent?: number | undefined; - readonly maxDepth?: number | undefined; - readonly maxWidth?: number | undefined; - readonly min?: boolean | undefined; - readonly printBasicPrototype?: boolean | undefined; - readonly printFunctionName?: boolean | undefined; - readonly theme?: { - readonly comment?: string | undefined; - readonly content?: string | undefined; - readonly prop?: string | undefined; - readonly tag?: string | undefined; - readonly value?: string | undefined; - } | undefined; - }; - errorOnDeprecated: boolean; - testEnvironment: string; - testEnvironmentOptions: Record; - testFailureExitCode: string | number; - testLocationInResults: boolean; - testMatch: string[]; - testNamePattern: string; - testPathIgnorePatterns: string[]; - testRegex: string | string[]; - testResultsProcessor: string; - testRunner: string; - testSequencer: string; - testTimeout: number; - transform: { - [regex: string]: string | JestConfig.TransformerConfig; - }; - transformIgnorePatterns: string[]; - watchPathIgnorePatterns: string[]; - unmockedModulePathPatterns: string[]; - updateSnapshot: boolean; - useStderr: boolean; - verbose?: boolean | undefined; - watch: boolean; - watchAll: boolean; - watchman: boolean; - watchPlugins: (string | [string, Record])[]; -}>; diff --git a/dist/lib/features/plugins.js b/dist/lib/features/plugins.js deleted file mode 100644 index d80551b0..00000000 --- a/dist/lib/features/plugins.js +++ /dev/null @@ -1,115 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.applyJestConfigPlugins = exports.applyDevServerConfigPlugins = exports.applyWebpackConfigPlugins = exports.applyCracoConfigPlugins = void 0; -var logger_1 = require("../logger"); -/************ Craco Config ************/ -function overrideCraco(_a, cracoConfig, context) { - var plugin = _a.plugin, options = _a.options; - if (plugin.overrideCracoConfig) { - var resultingConfig = plugin.overrideCracoConfig({ - cracoConfig: cracoConfig, - pluginOptions: options, - context: context, - }); - if (!resultingConfig) { - throw new Error('craco: Plugin returned an undefined craco config.'); - } - return resultingConfig; - } - (0, logger_1.log)('Overrided craco config with plugin.'); - return cracoConfig; -} -function applyCracoConfigPlugins(cracoConfig, context) { - if (cracoConfig.plugins) { - cracoConfig.plugins.forEach(function (plugin) { - cracoConfig = overrideCraco(plugin, cracoConfig, context); - }); - } - (0, logger_1.log)('Applied craco config plugins.'); - return cracoConfig; -} -exports.applyCracoConfigPlugins = applyCracoConfigPlugins; -/************ Webpack Config ************/ -function overrideWebpack(_a, cracoConfig, webpackConfig, context) { - var plugin = _a.plugin, options = _a.options; - if (plugin.overrideWebpackConfig) { - var resultingConfig = plugin.overrideWebpackConfig({ - cracoConfig: cracoConfig, - webpackConfig: webpackConfig, - pluginOptions: options, - context: context, - }); - if (!resultingConfig) { - throw new Error('craco: Plugin returned an undefined webpack config.'); - } - return resultingConfig; - } - (0, logger_1.log)('Overrided webpack config with plugin.'); - return webpackConfig; -} -function applyWebpackConfigPlugins(cracoConfig, webpackConfig, context) { - if (cracoConfig.plugins) { - cracoConfig.plugins.forEach(function (plugin) { - webpackConfig = overrideWebpack(plugin, cracoConfig, webpackConfig, context); - }); - } - (0, logger_1.log)('Applied webpack config plugins.'); - return webpackConfig; -} -exports.applyWebpackConfigPlugins = applyWebpackConfigPlugins; -/************ DevServer Config ************/ -function overrideDevServer(_a, cracoConfig, devServerConfig, context) { - var plugin = _a.plugin, options = _a.options; - if (plugin.overrideDevServerConfig) { - var resultingConfig = plugin.overrideDevServerConfig({ - cracoConfig: cracoConfig, - devServerConfig: devServerConfig, - pluginOptions: options, - context: context, - }); - if (!resultingConfig) { - throw new Error('craco: Plugin returned an undefined devServer config.'); - } - return resultingConfig; - } - (0, logger_1.log)('Overrided devServer config with plugin.'); - return devServerConfig; -} -function applyDevServerConfigPlugins(cracoConfig, devServerConfig, context) { - if (cracoConfig.plugins) { - cracoConfig.plugins.forEach(function (plugin) { - devServerConfig = overrideDevServer(plugin, cracoConfig, devServerConfig, context); - }); - } - (0, logger_1.log)('Applied devServer config plugins.'); - return devServerConfig; -} -exports.applyDevServerConfigPlugins = applyDevServerConfigPlugins; -/************ Jest Config *******************/ -function overrideJest(_a, cracoConfig, jestConfig, context) { - var plugin = _a.plugin, options = _a.options; - if (plugin.overrideJestConfig) { - var resultingConfig = plugin.overrideJestConfig({ - cracoConfig: cracoConfig, - jestConfig: jestConfig, - pluginOptions: options, - context: context, - }); - if (!resultingConfig) { - throw new Error('craco: Plugin returned an undefined Jest config.'); - } - return resultingConfig; - } - (0, logger_1.log)('Overrided Jest config with plugin.'); - return jestConfig; -} -function applyJestConfigPlugins(cracoConfig, jestConfig, context) { - if (cracoConfig.plugins) { - cracoConfig.plugins.forEach(function (plugin) { - jestConfig = overrideJest(plugin, cracoConfig, jestConfig, context); - }); - } - (0, logger_1.log)('Applied Jest config plugins.'); - return jestConfig; -} -exports.applyJestConfigPlugins = applyJestConfigPlugins; diff --git a/dist/lib/features/webpack/api.d.ts b/dist/lib/features/webpack/api.d.ts deleted file mode 100644 index 87187e13..00000000 --- a/dist/lib/features/webpack/api.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CliArgs } from '../../../types/args'; -import type { CracoConfig } from '../../../types/config'; -import type { WebpackContext } from '../../../types/context'; -export declare function createWebpackDevConfig(callerCracoConfig: CracoConfig, callerContext?: WebpackContext, options?: CliArgs): WebpackConfig; -export declare function createWebpackProdConfig(callerCracoConfig: CracoConfig, callerContext?: WebpackContext, options?: CliArgs): WebpackConfig; diff --git a/dist/lib/features/webpack/api.js b/dist/lib/features/webpack/api.js deleted file mode 100644 index c3ef153f..00000000 --- a/dist/lib/features/webpack/api.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createWebpackProdConfig = exports.createWebpackDevConfig = void 0; -var args_1 = require("../../args"); -var config_1 = require("../../config"); -var cra_1 = require("../../cra"); -var utils_1 = require("../../utils"); -var merge_webpack_config_1 = require("./merge-webpack-config"); -function createWebpackDevConfig(callerCracoConfig, callerContext, options) { - return createWebpackConfig(callerCracoConfig, callerContext, cra_1.loadWebpackDevConfig, 'development', options); -} -exports.createWebpackDevConfig = createWebpackDevConfig; -function createWebpackProdConfig(callerCracoConfig, callerContext, options) { - return createWebpackConfig(callerCracoConfig, callerContext, cra_1.loadWebpackProdConfig, 'production', options); -} -exports.createWebpackProdConfig = createWebpackProdConfig; -function createWebpackConfig(callerCracoConfig, callerContext, loadWebpackConfig, env, options) { - if (callerContext === void 0) { callerContext = {}; } - if (options === void 0) { options = {}; } - if (!callerCracoConfig) { - throw new Error("craco: 'cracoConfig' is required."); - } - if ((0, utils_1.isFunction)(callerCracoConfig)) { - throw new Error("craco: 'cracoConfig' should be an object."); - } - if (!process.env.NODE_ENV) { - process.env.NODE_ENV = env; - } - (0, args_1.setArgs)(options); - var context = __assign({ env: process.env.NODE_ENV }, callerContext); - var cracoConfig = (0, config_1.processCracoConfig)(callerCracoConfig, context); - context.paths = (0, cra_1.getCraPaths)(cracoConfig); - var craWebpackConfig = loadWebpackConfig(cracoConfig); - var resultingWebpackConfig = (0, merge_webpack_config_1.mergeWebpackConfig)(cracoConfig, craWebpackConfig, context); - return resultingWebpackConfig; -} diff --git a/dist/lib/features/webpack/babel.d.ts b/dist/lib/features/webpack/babel.d.ts deleted file mode 100644 index 5cb08655..00000000 --- a/dist/lib/features/webpack/babel.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoConfig } from '../../../types/config'; -import type { BaseContext } from '../../../types/context'; -export declare function overrideBabel(cracoConfig: CracoConfig, webpackConfig: WebpackConfig, context: BaseContext): WebpackConfig; diff --git a/dist/lib/features/webpack/babel.js b/dist/lib/features/webpack/babel.js deleted file mode 100644 index d5ac8740..00000000 --- a/dist/lib/features/webpack/babel.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideBabel = void 0; -var loaders_1 = require("../../loaders"); -var logger_1 = require("../../logger"); -var utils_1 = require("../../utils"); -// TODO: CRA use a cacheIdentifier, should we update it with the new plugins? -function addPresets(loader, babelPresets) { - if ((0, utils_1.isArray)(babelPresets)) { - if (loader.options && !(0, utils_1.isString)(loader.options)) { - if (loader.options.presets) { - loader.options.presets = - loader.options.presets.concat(babelPresets); - } - else { - loader.options.presets = babelPresets; - } - } - else { - loader.options = { - presets: babelPresets, - }; - } - } - (0, logger_1.log)('Added Babel presets.'); -} -function addPlugins(loader, babelPlugins) { - if ((0, utils_1.isArray)(babelPlugins)) { - if (loader.options && !(0, utils_1.isString)(loader.options)) { - if (loader.options.plugins) { - loader.options.plugins = - loader.options.plugins.concat(babelPlugins); - } - else { - loader.options.plugins = babelPlugins; - } - } - else { - loader.options = { - plugins: babelPlugins, - }; - } - } - (0, logger_1.log)('Added Babel plugins.'); -} -function applyLoaderOptions(loader, loaderOptions, context) { - if ((0, utils_1.isFunction)(loaderOptions)) { - loader.options = loaderOptions(loader.options || {}, context); - if (!loader.options) { - throw new Error("craco: 'babel.loaderOptions' function didn't return a loader config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - loader.options = (0, utils_1.deepMergeWithArray)({}, loader.options || {}, loaderOptions); - } - (0, logger_1.log)('Applied Babel loader options.'); -} -function overrideLoader(match, babelConfig, context) { - var presets = babelConfig.presets, plugins = babelConfig.plugins, loaderOptions = babelConfig.loaderOptions; - if (presets) { - addPresets(match.loader, presets); - } - if (plugins) { - addPlugins(match.loader, plugins); - } - if (loaderOptions) { - applyLoaderOptions(match.loader, loaderOptions, context); - } -} -function overrideBabel(cracoConfig, webpackConfig, context) { - if (cracoConfig.babel) { - var _a = (0, loaders_1.getLoaders)(webpackConfig, (0, loaders_1.loaderByName)('babel-loader')), hasFoundAny = _a.hasFoundAny, matches = _a.matches; - if (!hasFoundAny) { - (0, logger_1.logError)('Cannot find any Babel loaders.'); - return webpackConfig; - } - matches.forEach(function (x) { - overrideLoader(x, cracoConfig, context); - }); - } - return webpackConfig; -} -exports.overrideBabel = overrideBabel; diff --git a/dist/lib/features/webpack/eslint.d.ts b/dist/lib/features/webpack/eslint.d.ts deleted file mode 100644 index 89fd06a4..00000000 --- a/dist/lib/features/webpack/eslint.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoConfig } from '../../../types/config'; -import type { BaseContext } from '../../../types/context'; -export declare function overrideEsLint(cracoConfig: CracoConfig, webpackConfig: WebpackConfig, context: BaseContext): WebpackConfig; diff --git a/dist/lib/features/webpack/eslint.js b/dist/lib/features/webpack/eslint.js deleted file mode 100644 index de54679a..00000000 --- a/dist/lib/features/webpack/eslint.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideEsLint = void 0; -var logger_1 = require("../../logger"); -var utils_1 = require("../../utils"); -var webpack_plugins_1 = require("../../webpack-plugins"); -function disableEslint(webpackConfig) { - var hasRemovedAny = (0, webpack_plugins_1.removePlugins)(webpackConfig, (0, webpack_plugins_1.pluginByName)('ESLintWebpackPlugin')).hasRemovedAny; - if (hasRemovedAny) { - (0, logger_1.log)('Disabled ESLint.'); - } - else { - (0, logger_1.logError)("Couldn't disabled ESLint."); - } -} -function extendsEslintConfig(plugin, eslintConfig, context) { - var configure = eslintConfig.configure; - if (configure) { - if ((0, utils_1.isFunction)(configure)) { - if (plugin.options) { - plugin.options.baseConfig = configure(plugin.options.baseConfig || {}, context); - } - else { - plugin.options = { - baseConfig: configure({}, context), - }; - } - if (!plugin.options.baseConfig) { - throw new Error("craco: 'eslint.configure' function didn't return a config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - if (plugin.options) { - plugin.options.baseConfig = (0, utils_1.deepMergeWithArray)({}, plugin.options.baseConfig || {}, configure); - } - else { - plugin.options = { - baseConfig: configure, - }; - } - } - (0, logger_1.log)("Merged ESLint config with 'eslint.configure'."); - } -} -function useEslintConfigFile(plugin) { - if (plugin.options) { - plugin.options.useEslintrc = true; - delete plugin.options.baseConfig; - } - else { - plugin.options = { - useEslintrc: true, - }; - } - (0, logger_1.log)('Overrided ESLint config to use a config file.'); -} -function enableEslintIgnoreFile(plugin) { - if (plugin.options) { - plugin.options.ignore = true; - } - else { - plugin.options = { - ignore: true, - }; - } - (0, logger_1.log)('Overrided ESLint config to enable an ignore file.'); -} -function applyPluginOptions(plugin, pluginOptions, context) { - if ((0, utils_1.isFunction)(pluginOptions)) { - plugin.options = pluginOptions(plugin.options || {}, context); - if (!plugin.options) { - throw new Error("craco: 'eslint.pluginOptions' function didn't return a config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - plugin.options = (0, utils_1.deepMergeWithArray)(plugin.options || {}, pluginOptions); - } - (0, logger_1.log)('Applied ESLint plugin options.'); -} -function overrideEsLint(cracoConfig, webpackConfig, context) { - if (cracoConfig.eslint) { - var _a = (0, webpack_plugins_1.getPlugin)(webpackConfig, (0, webpack_plugins_1.pluginByName)('ESLintWebpackPlugin')), isFound = _a.isFound, match = _a.match; - if (!isFound) { - (0, logger_1.logError)('Cannot find ESLint plugin (ESLintWebpackPlugin).'); - return webpackConfig; - } - var _b = cracoConfig.eslint, enable = _b.enable, mode = _b.mode, pluginOptions = _b.pluginOptions; - if (enable === false) { - disableEslint(webpackConfig); - return webpackConfig; - } - enableEslintIgnoreFile(match); - if (mode === 'file') { - useEslintConfigFile(match); - } - else { - extendsEslintConfig(match, cracoConfig.eslint, context); - } - if (pluginOptions) { - applyPluginOptions(match, pluginOptions, context); - } - } - return webpackConfig; -} -exports.overrideEsLint = overrideEsLint; diff --git a/dist/lib/features/webpack/merge-webpack-config.d.ts b/dist/lib/features/webpack/merge-webpack-config.d.ts deleted file mode 100644 index 82a12103..00000000 --- a/dist/lib/features/webpack/merge-webpack-config.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoConfig } from '../../../types/config'; -import type { WebpackContext } from '../../../types/context'; -export declare function mergeWebpackConfig(cracoConfig: CracoConfig, webpackConfig: WebpackConfig, context: WebpackContext): WebpackConfig; diff --git a/dist/lib/features/webpack/merge-webpack-config.js b/dist/lib/features/webpack/merge-webpack-config.js deleted file mode 100644 index 309506e8..00000000 --- a/dist/lib/features/webpack/merge-webpack-config.js +++ /dev/null @@ -1,122 +0,0 @@ -"use strict"; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.mergeWebpackConfig = void 0; -var webpack_merge_1 = __importDefault(require("webpack-merge")); -var logger_1 = require("../../logger"); -var utils_1 = require("../../utils"); -var webpack_plugins_1 = require("../../webpack-plugins"); -var plugins_1 = require("../plugins"); -var babel_1 = require("./babel"); -var eslint_1 = require("./eslint"); -var style_1 = require("./style/style"); -var typescript_1 = require("./typescript"); -function addAlias(webpackConfig, webpackAlias) { - if (webpackConfig.resolve) { - // TODO: ensure is a plain object, if not, log an error. - webpackConfig.resolve.alias = Object.assign(webpackConfig.resolve.alias || {}, webpackAlias); - } - (0, logger_1.log)('Added webpack alias.'); -} -function addPlugins(webpackConfig, webpackPlugins) { - if ((0, utils_1.isArray)(webpackPlugins)) { - (0, webpack_plugins_1.addPlugins)(webpackConfig, webpackPlugins); - (0, logger_1.log)('Added webpack plugins.'); - } - else { - throw new Error("craco: 'webpack.plugins.add' needs to be a an array of plugins"); - } -} -function removePluginsFromWebpackConfig(webpackConfig, remove) { - var e_1, _a; - if (!remove) { - return; - } - if ((0, utils_1.isArray)(remove)) { - try { - for (var remove_1 = __values(remove), remove_1_1 = remove_1.next(); !remove_1_1.done; remove_1_1 = remove_1.next()) { - var pluginName = remove_1_1.value; - var hasRemovedAny = (0, webpack_plugins_1.removePlugins)(webpackConfig, (0, webpack_plugins_1.pluginByName)(pluginName)).hasRemovedAny; - if (hasRemovedAny) { - (0, logger_1.log)("Removed webpack plugin ".concat(pluginName, ".")); - } - else { - (0, logger_1.log)("Did not remove webpack plugin ".concat(pluginName, ".")); - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (remove_1_1 && !remove_1_1.done && (_a = remove_1.return)) _a.call(remove_1); - } - finally { if (e_1) throw e_1.error; } - } - (0, logger_1.log)('Removed webpack plugins.'); - } - else { - throw new Error("craco: 'webpack.plugins.remove' needs to be a an array of plugin names"); - } -} -function giveTotalControl(webpackConfig, configureWebpack, context) { - if ((0, utils_1.isFunction)(configureWebpack)) { - webpackConfig = configureWebpack(webpackConfig, context); - if (!webpackConfig) { - throw new Error("craco: 'webpack.configure' function didn't returned a webpack config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - webpackConfig = (0, webpack_merge_1.default)(webpackConfig, configureWebpack); - } - (0, logger_1.log)("Merged webpack config with 'webpack.configure'."); - return webpackConfig; -} -function mergeWebpackConfig(cracoConfig, webpackConfig, context) { - var resultingWebpackConfig = webpackConfig; - resultingWebpackConfig = (0, babel_1.overrideBabel)(cracoConfig, resultingWebpackConfig, context); - resultingWebpackConfig = (0, eslint_1.overrideEsLint)(cracoConfig, resultingWebpackConfig, context); - resultingWebpackConfig = (0, style_1.overrideStyle)(cracoConfig, resultingWebpackConfig, context); - resultingWebpackConfig = (0, typescript_1.overrideTypeScript)(cracoConfig, resultingWebpackConfig); - if (cracoConfig.webpack) { - var _a = cracoConfig.webpack, alias = _a.alias, plugins = _a.plugins, configure = _a.configure; - if (alias) { - addAlias(resultingWebpackConfig, alias); - } - if (plugins) { - // we still support the old format of plugin: [] where the array is a list of the plugins to add - if ((0, utils_1.isArray)(plugins)) { - addPlugins(resultingWebpackConfig, plugins); - } - else { - var add = plugins.add, remove = plugins.remove; - if (remove) { - removePluginsFromWebpackConfig(resultingWebpackConfig, remove); - } - // Add after removing to preserve any plugins explicitely added via the Craco config - if (add) { - addPlugins(resultingWebpackConfig, add); - } - } - } - if (configure) { - resultingWebpackConfig = giveTotalControl(resultingWebpackConfig, configure, context); - } - } - resultingWebpackConfig = (0, plugins_1.applyWebpackConfigPlugins)(cracoConfig, resultingWebpackConfig, context); - return resultingWebpackConfig; -} -exports.mergeWebpackConfig = mergeWebpackConfig; diff --git a/dist/lib/features/webpack/override.d.ts b/dist/lib/features/webpack/override.d.ts deleted file mode 100644 index 1e71339e..00000000 --- a/dist/lib/features/webpack/override.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { CracoConfig } from '../../../types/config'; -import type { WebpackContext } from '../../../types/context'; -export declare function overrideWebpackDev(cracoConfig: CracoConfig, context: WebpackContext): void; -export declare function overrideWebpackProd(cracoConfig: CracoConfig, context: WebpackContext): void; diff --git a/dist/lib/features/webpack/override.js b/dist/lib/features/webpack/override.js deleted file mode 100644 index f75c51dc..00000000 --- a/dist/lib/features/webpack/override.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideWebpackProd = exports.overrideWebpackDev = void 0; -var cra_1 = require("../../cra"); -var merge_webpack_config_1 = require("./merge-webpack-config"); -function overrideWebpackDev(cracoConfig, context) { - var craWebpackConfig = (0, cra_1.loadWebpackDevConfig)(cracoConfig); - var resultingWebpackConfig = (0, merge_webpack_config_1.mergeWebpackConfig)(cracoConfig, craWebpackConfig, context); - (0, cra_1.overrideWebpackDevConfig)(cracoConfig, resultingWebpackConfig); -} -exports.overrideWebpackDev = overrideWebpackDev; -function overrideWebpackProd(cracoConfig, context) { - var craWebpackConfig = (0, cra_1.loadWebpackProdConfig)(cracoConfig); - var resultingWebpackConfig = (0, merge_webpack_config_1.mergeWebpackConfig)(cracoConfig, craWebpackConfig, context); - (0, cra_1.overrideWebpackProdConfig)(cracoConfig, resultingWebpackConfig); -} -exports.overrideWebpackProd = overrideWebpackProd; diff --git a/dist/lib/features/webpack/style/css.d.ts b/dist/lib/features/webpack/style/css.d.ts deleted file mode 100644 index 72dc342c..00000000 --- a/dist/lib/features/webpack/style/css.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoStyleConfig } from '../../../../types/config'; -import type { BaseContext } from '../../../../types/context'; -export declare function overrideCss(styleConfig: CracoStyleConfig, webpackConfig: WebpackConfig, context: BaseContext): WebpackConfig; diff --git a/dist/lib/features/webpack/style/css.js b/dist/lib/features/webpack/style/css.js deleted file mode 100644 index ed4b477c..00000000 --- a/dist/lib/features/webpack/style/css.js +++ /dev/null @@ -1,75 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideCss = void 0; -var loaders_1 = require("../../../loaders"); -var logger_1 = require("../../../logger"); -var utils_1 = require("../../../utils"); -function setModuleLocalIdentName(match, localIdentName) { - var _a, _b; - // The css-loader version of create-react-app has changed from 2.1.1 to 3.2.0 - // https://github.com/facebook/create-react-app/commit/f79f30 - if ((0, utils_1.isBoolean)(match.loader.options.modules)) { - (_b = (_a = match.loader) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? true : delete _b.getLocalIdent; - match.loader.options.localIdentName = localIdentName; - } - else { - // This setting applies to create-react-app@3.3.0 - delete match.loader.options.modules.getLocalIdent; - match.loader.options.modules.localIdentName = localIdentName; - } - (0, logger_1.log)('Overrided CSS modules local ident name.'); -} -function applyLoaderOptions(match, loaderOptions, context) { - if ((0, utils_1.isFunction)(loaderOptions)) { - match.loader.options = loaderOptions(match.loader.options || {}, context); - if (!match.loader.options) { - throw new Error("craco: 'style.css.loaderOptions' function didn't return a loader config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - match.loader.options = (0, utils_1.deepMergeWithArray)({}, match.loader.options || {}, loaderOptions); - } - (0, logger_1.log)('Applied CSS loaders options.'); -} -function overrideCssLoader(match, _a, context) { - var cssOptions = _a.css; - if (cssOptions === null || cssOptions === void 0 ? void 0 : cssOptions.loaderOptions) { - applyLoaderOptions(match, cssOptions.loaderOptions, context); - (0, logger_1.log)('Overrided CSS loader.'); - } -} -function overrideModuleLoader(match, modulesOptions) { - if (modulesOptions === null || modulesOptions === void 0 ? void 0 : modulesOptions.localIdentName) { - setModuleLocalIdentName(match, modulesOptions.localIdentName); - (0, logger_1.log)('Overrided CSS module loader.'); - } -} -function overrideCss(styleConfig, webpackConfig, context) { - if (styleConfig.modules || styleConfig.css) { - var _a = (0, loaders_1.getLoaders)(webpackConfig, (0, loaders_1.loaderByName)('css-loader')), hasFoundAny = _a.hasFoundAny, matches = _a.matches; - if (!hasFoundAny) { - (0, logger_1.logError)('Cannot find any CSS loaders.'); - return webpackConfig; - } - if (styleConfig.modules) { - var cssModuleLoaders = matches.filter(function (x) { - var _a, _b; - return !(0, utils_1.isString)(x.loader) && - ((_a = x.loader) === null || _a === void 0 ? void 0 : _a.options) && - !(0, utils_1.isString)((_b = x.loader) === null || _b === void 0 ? void 0 : _b.options) && - x.loader.options.modules; - }); - cssModuleLoaders.forEach(function (x) { - overrideModuleLoader(x, styleConfig.modules); - }); - } - if (styleConfig.css) { - matches.forEach(function (x) { - overrideCssLoader(x, styleConfig, context); - }); - } - } - return webpackConfig; -} -exports.overrideCss = overrideCss; diff --git a/dist/lib/features/webpack/style/postcss.d.ts b/dist/lib/features/webpack/style/postcss.d.ts deleted file mode 100644 index 5dbb142f..00000000 --- a/dist/lib/features/webpack/style/postcss.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoStyleConfig } from '../../../../types/config'; -import type { BaseContext } from '../../../../types/context'; -export declare function overridePostcss(styleConfig: CracoStyleConfig, webpackConfig: WebpackConfig, context: BaseContext): WebpackConfig; diff --git a/dist/lib/features/webpack/style/postcss.js b/dist/lib/features/webpack/style/postcss.js deleted file mode 100644 index 48e7a682..00000000 --- a/dist/lib/features/webpack/style/postcss.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overridePostcss = void 0; -var lodash_1 = require("lodash"); -var loaders_1 = require("../../../loaders"); -var logger_1 = require("../../../logger"); -var paths_1 = require("../../../paths"); -var utils_1 = require("../../../utils"); -var CRA_PLUGINS = function (presetEnv) { - // prettier-ignore - return [ - require("postcss-flexbugs-fixes"), - require("postcss-preset-env")(presetEnv), - require(require.resolve("postcss-normalize", { paths: [paths_1.projectRoot] })) - ]; -}; -var CRA_PRESET_ENV = { - autoprefixer: { - flexbox: 'no-2009', - }, - stage: 3, -}; -function usePostcssConfigFile(match) { - var _a, _b, _c; - if (!(0, lodash_1.isString)((_a = match.loader) === null || _a === void 0 ? void 0 : _a.options) && - ((_c = (_b = match.loader) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.postcssOptions)) { - var ident = match.loader.options.postcssOptions.ident; - var sourceMap = match.loader.options.postcssOptions.sourceMap; - match.loader.options.postcssOptions = { - ident: ident, - sourceMap: sourceMap, - }; - (0, logger_1.log)('Overwrited PostCSS config to use a config file.'); - } -} -function extendsPostcss(match, _a) { - var _b; - var postcssOptions = _a.postcss; - var _c = postcssOptions !== null && postcssOptions !== void 0 ? postcssOptions : {}, plugins = _c.plugins, env = _c.env; - if ((0, utils_1.isArray)(plugins) || env) { - var postcssPlugins_1; - if (env) { - var mergedPreset = (0, utils_1.deepMergeWithArray)({}, CRA_PRESET_ENV, env); - postcssPlugins_1 = CRA_PLUGINS(mergedPreset); - (0, logger_1.log)('Merged PostCSS env preset.'); - } - else { - var craPlugins = []; - if (!(0, lodash_1.isString)(match.loader.options)) { - var options = (_b = match.loader.options) === null || _b === void 0 ? void 0 : _b.postcssOptions; - if ((0, utils_1.isFunction)(options)) { - craPlugins = options().plugins; - } - else { - craPlugins = options === null || options === void 0 ? void 0 : options.plugins; - } - } - postcssPlugins_1 = craPlugins || []; - } - if (plugins) { - postcssPlugins_1 = (0, utils_1.isFunction)(plugins) - ? plugins(postcssPlugins_1) - : postcssPlugins_1.concat(plugins); - (0, logger_1.log)('Added PostCSS plugins.'); - } - if (match.loader.options && !(0, lodash_1.isString)(match.loader.options)) { - if (match.loader.options.postcssOptions) { - match.loader.options.postcssOptions.plugins = function () { - return postcssPlugins_1; - }; - } - else { - match.loader.options.postcssOptions = { - plugins: function () { return postcssPlugins_1; }, - }; - } - } - } -} -function applyLoaderOptions(match, loaderOptions, context) { - if ((0, utils_1.isFunction)(loaderOptions)) { - match.loader.options = loaderOptions(match.loader.options || {}, context); - if (!match.loader.options) { - throw new Error("craco: 'style.postcss.loaderOptions' function didn't return a loader config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - match.loader.options = (0, utils_1.deepMergeWithArray)({}, match.loader.options || {}, loaderOptions); - } - (0, logger_1.log)('Applied PostCSS loaders options.'); -} -function overrideLoader(match, styleConfig, context) { - var _a; - var _b = (_a = styleConfig.postcss) !== null && _a !== void 0 ? _a : {}, mode = _b.mode, loaderOptions = _b.loaderOptions; - if (mode === 'file') { - usePostcssConfigFile(match); - } - else { - extendsPostcss(match, styleConfig); - } - if (loaderOptions) { - applyLoaderOptions(match, loaderOptions, context); - } - (0, logger_1.log)('Overrided PostCSS loader.'); -} -function overridePostcss(styleConfig, webpackConfig, context) { - if (styleConfig.postcss) { - var _a = (0, loaders_1.getLoaders)(webpackConfig, (0, loaders_1.loaderByName)('postcss-loader')), hasFoundAny = _a.hasFoundAny, matches = _a.matches; - if (!hasFoundAny) { - (0, logger_1.logError)('Cannot find any PostCSS loaders.'); - return webpackConfig; - } - matches.forEach(function (x) { - overrideLoader(x, styleConfig, context); - }); - } - return webpackConfig; -} -exports.overridePostcss = overridePostcss; diff --git a/dist/lib/features/webpack/style/sass.d.ts b/dist/lib/features/webpack/style/sass.d.ts deleted file mode 100644 index 11456e80..00000000 --- a/dist/lib/features/webpack/style/sass.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoStyleConfig } from '../../../../types/config'; -import { BaseContext } from '../../../../types/context'; -export declare function overrideSass(styleConfig: CracoStyleConfig, webpackConfig: WebpackConfig, context: BaseContext): WebpackConfig; diff --git a/dist/lib/features/webpack/style/sass.js b/dist/lib/features/webpack/style/sass.js deleted file mode 100644 index 5c167b36..00000000 --- a/dist/lib/features/webpack/style/sass.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideSass = void 0; -var loaders_1 = require("../../../loaders"); -var logger_1 = require("../../../logger"); -var utils_1 = require("../../../utils"); -function setLoaderProperty(match, key, valueProviders) { - var _a; - if ((0, utils_1.isString)(match.loader)) { - match.parent[match.index] = (_a = { - loader: match.loader - }, - _a[key] = valueProviders.whenString(), - _a); - } - else { - match.loader[key] = valueProviders.whenObject(); - } -} -function applyLoaderOptions(match, loaderOptions, context) { - if ((0, utils_1.isFunction)(loaderOptions)) { - setLoaderProperty(match, 'options', { - whenString: function () { return loaderOptions({}, context); }, - whenObject: function () { - return loaderOptions(match.loader.options || {}, context); - }, - }); - if (!match.loader.options) { - throw new Error("craco: 'style.sass.loaderOptions' function didn't return a loader config object."); - } - } - else { - // TODO: ensure is otherwise a plain object, if not, log an error. - setLoaderProperty(match, 'options', { - whenString: function () { return loaderOptions; }, - whenObject: function () { - return (0, utils_1.deepMergeWithArray)({}, match.loader.options || {}, loaderOptions); - }, - }); - } - (0, logger_1.log)('Applied Sass loaders options.'); -} -function overrideLoader(match, _a, context) { - var sassOptions = _a.sass; - var loaderOptions = (sassOptions !== null && sassOptions !== void 0 ? sassOptions : {}).loaderOptions; - if (loaderOptions) { - applyLoaderOptions(match, loaderOptions, context); - (0, logger_1.log)('Overrided Sass loader.'); - } -} -function overrideSass(styleConfig, webpackConfig, context) { - if (styleConfig.sass) { - var _a = (0, loaders_1.getLoaders)(webpackConfig, (0, loaders_1.loaderByName)('sass-loader')), hasFoundAny = _a.hasFoundAny, matches = _a.matches; - if (!hasFoundAny) { - (0, logger_1.logError)('Cannot find any Sass loaders.'); - return webpackConfig; - } - matches.forEach(function (x) { - overrideLoader(x, styleConfig, context); - }); - } - return webpackConfig; -} -exports.overrideSass = overrideSass; diff --git a/dist/lib/features/webpack/style/style.d.ts b/dist/lib/features/webpack/style/style.d.ts deleted file mode 100644 index 5c3d2d29..00000000 --- a/dist/lib/features/webpack/style/style.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoConfig } from '../../../../types/config'; -import type { BaseContext } from '../../../../types/context'; -export declare function overrideStyle(cracoConfig: CracoConfig, webpackConfig: WebpackConfig, context: BaseContext): WebpackConfig; diff --git a/dist/lib/features/webpack/style/style.js b/dist/lib/features/webpack/style/style.js deleted file mode 100644 index 0e515a44..00000000 --- a/dist/lib/features/webpack/style/style.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideStyle = void 0; -var css_1 = require("./css"); -var postcss_1 = require("./postcss"); -var sass_1 = require("./sass"); -function overrideStyle(cracoConfig, webpackConfig, context) { - if (cracoConfig.style) { - webpackConfig = (0, css_1.overrideCss)(cracoConfig.style, webpackConfig, context); - webpackConfig = (0, sass_1.overrideSass)(cracoConfig.style, webpackConfig, context); - webpackConfig = (0, postcss_1.overridePostcss)(cracoConfig.style, webpackConfig, context); - } - return webpackConfig; -} -exports.overrideStyle = overrideStyle; diff --git a/dist/lib/features/webpack/typescript.d.ts b/dist/lib/features/webpack/typescript.d.ts deleted file mode 100644 index 3b797aa9..00000000 --- a/dist/lib/features/webpack/typescript.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -import type { CracoConfig } from '../../../types/config'; -export declare function overrideTypeScript(cracoConfig: CracoConfig, webpackConfig: WebpackConfig): WebpackConfig; diff --git a/dist/lib/features/webpack/typescript.js b/dist/lib/features/webpack/typescript.js deleted file mode 100644 index 5b91c589..00000000 --- a/dist/lib/features/webpack/typescript.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.overrideTypeScript = void 0; -var logger_1 = require("../../logger"); -function disableTypeChecking(webpackConfig) { - var _a; - webpackConfig.plugins = (_a = webpackConfig.plugins) === null || _a === void 0 ? void 0 : _a.filter(function (plugin) { return plugin.constructor.name !== 'ForkTsCheckerWebpackPlugin'; }); - (0, logger_1.log)('Disabled TypeScript type checking.'); - return webpackConfig; -} -function overrideTypeScript(cracoConfig, webpackConfig) { - if (cracoConfig.typescript) { - var enableTypeChecking = cracoConfig.typescript.enableTypeChecking; - if (enableTypeChecking === false) { - disableTypeChecking(webpackConfig); - } - } - return webpackConfig; -} -exports.overrideTypeScript = overrideTypeScript; diff --git a/dist/lib/loaders.d.ts b/dist/lib/loaders.d.ts deleted file mode 100644 index 77cc826b..00000000 --- a/dist/lib/loaders.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Configuration as WebpackConfig, RuleSetRule, RuleSetUseItem } from 'webpack'; -import type { Loader, LoaderMatcher, Rule } from '../types/loaders'; -export declare function loaderByName(targetLoaderName: string): (rule: RuleSetRule | RuleSetUseItem) => boolean; -export declare function getLoader(webpackConfig: WebpackConfig, matcher: LoaderMatcher): { - isFound: boolean; - match: Loader | undefined; -}; -export declare function getLoaders(webpackConfig: WebpackConfig, matcher: LoaderMatcher): { - hasFoundAny: boolean; - matches: Loader[]; -}; -export declare function removeLoaders(webpackConfig: WebpackConfig, matcher: LoaderMatcher): { - hasRemovedAny: boolean; - removedCount: number; -}; -export declare const addBeforeLoader: (webpackConfig: WebpackConfig, matcher: LoaderMatcher, newLoader: Rule) => { - isAdded: boolean; -}; -export declare const addAfterLoader: (webpackConfig: WebpackConfig, matcher: LoaderMatcher, newLoader: Rule) => { - isAdded: boolean; -}; -export declare const addBeforeLoaders: (webpackConfig: WebpackConfig, matcher: LoaderMatcher, newLoader: Rule) => { - isAdded: boolean; - addedCount: number; -}; -export declare const addAfterLoaders: (webpackConfig: WebpackConfig, matcher: LoaderMatcher, newLoader: Rule) => { - isAdded: boolean; - addedCount: number; -}; diff --git a/dist/lib/loaders.js b/dist/lib/loaders.js deleted file mode 100644 index 002b446c..00000000 --- a/dist/lib/loaders.js +++ /dev/null @@ -1,168 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.addAfterLoaders = exports.addBeforeLoaders = exports.addAfterLoader = exports.addBeforeLoader = exports.removeLoaders = exports.getLoaders = exports.getLoader = exports.loaderByName = void 0; -var path_1 = __importDefault(require("path")); -var utils_1 = require("./utils"); -function loaderByName(targetLoaderName) { - return function (rule) { - if (!(0, utils_1.isString)(rule) && 'loader' in rule && (0, utils_1.isString)(rule.loader)) { - return (rule.loader.indexOf("".concat(path_1.default.sep).concat(targetLoaderName).concat(path_1.default.sep)) !== -1 || - rule.loader.indexOf("@".concat(targetLoaderName).concat(path_1.default.sep)) !== -1); - } - else if ((0, utils_1.isString)(rule)) { - return (rule.indexOf("".concat(path_1.default.sep).concat(targetLoaderName).concat(path_1.default.sep)) !== - -1 || rule.indexOf("@".concat(targetLoaderName).concat(path_1.default.sep)) !== -1); - } - return false; - }; -} -exports.loaderByName = loaderByName; -var toMatchingLoader = function (loader, parent, index) { return ({ loader: loader, parent: parent, index: index }); }; -function getLoaderRecursively(rules, matcher) { - var loader; - rules === null || rules === void 0 ? void 0 : rules.some(function (rule, index) { - if (rule) { - if (matcher(rule)) { - loader = toMatchingLoader(rule, rules, index); - } - else if (!(0, utils_1.isString)(rule)) { - if (rule.use) { - if ((0, utils_1.isString)(rule.use) && matcher(rule.use)) { - loader = toMatchingLoader({ loader: rule.use }, rules, index); - } - else { - loader = getLoaderRecursively(rule.use, matcher); - } - } - else if (rule.oneOf) { - loader = getLoaderRecursively(rule.oneOf, matcher); - } - else if ((0, utils_1.isArray)(rule.loader)) { - loader = getLoaderRecursively(rule.loader, matcher); - } - } - } - return loader !== undefined; - }); - return loader; -} -function getLoader(webpackConfig, matcher) { - var _a; - var matchingLoader = getLoaderRecursively((_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules, matcher); - return { isFound: matchingLoader !== undefined, match: matchingLoader }; -} -exports.getLoader = getLoader; -function getLoadersRecursively(rules, matcher, matchingLoaders) { - rules === null || rules === void 0 ? void 0 : rules.forEach(function (rule, index) { - if (rule) { - if (matcher(rule)) { - matchingLoaders.push(toMatchingLoader(rule, rules, index)); - } - else if (!(0, utils_1.isString)(rule)) { - if (rule.use) { - if ((0, utils_1.isString)(rule.use) && matcher(rule.use)) { - matchingLoaders.push(toMatchingLoader({ loader: rule.use }, rules, index)); - } - else { - getLoadersRecursively(rule.use, matcher, matchingLoaders); - } - } - else if (rule.oneOf) { - getLoadersRecursively(rule.oneOf, matcher, matchingLoaders); - } - else if ((0, utils_1.isArray)(rule.loader)) { - getLoadersRecursively(rule.loader, matcher, matchingLoaders); - } - } - } - }); -} -function getLoaders(webpackConfig, matcher) { - var _a; - var matchingLoaders = []; - getLoadersRecursively((_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules, matcher, matchingLoaders); - return { - hasFoundAny: matchingLoaders.length !== 0, - matches: matchingLoaders, - }; -} -exports.getLoaders = getLoaders; -function removeLoadersRecursively(rules, matcher) { - var toRemove = []; - var removedCount = 0; - if (!rules) { - return { rules: rules, removedCount: 0 }; - } - for (var i = 0, max = rules.length; i < max; i += 1) { - var rule = rules[i]; - if (rule) { - if (matcher(rule)) { - toRemove.push(i); - } - else if (!(0, utils_1.isString)(rule)) { - if (rule.use) { - var result = void 0; - if ((0, utils_1.isString)(rule.use) && matcher(rule.use)) { - toRemove.push(i); - removedCount++; - rule.use = undefined; - } - else { - result = removeLoadersRecursively(rule.use, matcher); - removedCount += result.removedCount; - rule.use = result.rules; - } - } - else if (rule.oneOf) { - var result = removeLoadersRecursively(rule.oneOf, matcher); - removedCount += result.removedCount; - rule.oneOf = result.rules; - } - } - } - } - toRemove.forEach(function (ruleIndex, i) { - rules.splice(ruleIndex - i, 1); - }); - return { rules: rules, removedCount: removedCount + toRemove.length }; -} -function removeLoaders(webpackConfig, matcher) { - var _a; - var result = removeLoadersRecursively((_a = webpackConfig.module) === null || _a === void 0 ? void 0 : _a.rules, matcher); - return { - hasRemovedAny: result.removedCount > 0, - removedCount: result.removedCount, - }; -} -exports.removeLoaders = removeLoaders; -function addLoader(webpackConfig, matcher, newLoader, positionAdapter) { - var _a; - var _b = getLoader(webpackConfig, matcher), isFound = _b.isFound, match = _b.match; - if (isFound) { - (_a = match.parent) === null || _a === void 0 ? void 0 : _a.splice(positionAdapter(match.index), 0, newLoader); - return { isAdded: true }; - } - return { isAdded: false }; -} -var addBeforeLoader = function (webpackConfig, matcher, newLoader) { return addLoader(webpackConfig, matcher, newLoader, function (x) { return x; }); }; -exports.addBeforeLoader = addBeforeLoader; -var addAfterLoader = function (webpackConfig, matcher, newLoader) { return addLoader(webpackConfig, matcher, newLoader, function (x) { return x + 1; }); }; -exports.addAfterLoader = addAfterLoader; -function addLoaders(webpackConfig, matcher, newLoader, positionAdapter) { - var _a = getLoaders(webpackConfig, matcher), hasFoundAny = _a.hasFoundAny, matches = _a.matches; - if (hasFoundAny) { - matches.forEach(function (match) { - var _a; - (_a = match.parent) === null || _a === void 0 ? void 0 : _a.splice(positionAdapter(match.index), 0, newLoader); - }); - return { isAdded: true, addedCount: matches.length }; - } - return { isAdded: false, addedCount: 0 }; -} -var addBeforeLoaders = function (webpackConfig, matcher, newLoader) { return addLoaders(webpackConfig, matcher, newLoader, function (x) { return x; }); }; -exports.addBeforeLoaders = addBeforeLoaders; -var addAfterLoaders = function (webpackConfig, matcher, newLoader) { return addLoaders(webpackConfig, matcher, newLoader, function (x) { return x + 1; }); }; -exports.addAfterLoaders = addAfterLoaders; diff --git a/dist/lib/logger.d.ts b/dist/lib/logger.d.ts deleted file mode 100644 index c59175ff..00000000 --- a/dist/lib/logger.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare function log(...rest: any[]): void; -export declare function logError(...rest: any[]): void; diff --git a/dist/lib/logger.js b/dist/lib/logger.js deleted file mode 100644 index 41620971..00000000 --- a/dist/lib/logger.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.logError = exports.log = void 0; -var args_1 = require("./args"); -function log() { - var rest = []; - for (var _i = 0; _i < arguments.length; _i++) { - rest[_i] = arguments[_i]; - } - if ((0, args_1.getArgs)().verbose) { - console.log.apply(console, __spreadArray([], __read(rest), false)); - } -} -exports.log = log; -function logError() { - var rest = []; - for (var _i = 0; _i < arguments.length; _i++) { - rest[_i] = arguments[_i]; - } - console.error.apply(console, __spreadArray([], __read(rest), false)); -} -exports.logError = logError; diff --git a/dist/lib/paths.d.ts b/dist/lib/paths.d.ts deleted file mode 100644 index f88fa8a1..00000000 --- a/dist/lib/paths.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare const projectRoot: string; diff --git a/dist/lib/paths.js b/dist/lib/paths.js deleted file mode 100644 index 95f15ccd..00000000 --- a/dist/lib/paths.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.projectRoot = void 0; -var fs_1 = __importDefault(require("fs")); -var logger_1 = require("./logger"); -exports.projectRoot = fs_1.default.realpathSync(process.cwd()); -(0, logger_1.log)('Project root path resolved to: ', exports.projectRoot); diff --git a/dist/lib/plugin-utils.d.ts b/dist/lib/plugin-utils.d.ts deleted file mode 100644 index 6c9f1624..00000000 --- a/dist/lib/plugin-utils.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { ConfigError } from '../types/plugin-utils'; -export declare function gitHubIssueUrl(repo: string, query?: string): string; -export declare function throwUnexpectedConfigError({ message, packageName, githubRepo: repo, githubIssueQuery: query, }: ConfigError): void; diff --git a/dist/lib/plugin-utils.js b/dist/lib/plugin-utils.js deleted file mode 100644 index 2189bed3..00000000 --- a/dist/lib/plugin-utils.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.throwUnexpectedConfigError = exports.gitHubIssueUrl = void 0; -function gitHubIssueUrl(repo, query) { - return "https://github.com/".concat(repo, "/issues?q=is%3Aissue").concat(query ? "+".concat(query) : ''); -} -exports.gitHubIssueUrl = gitHubIssueUrl; -function showNpmPackageUrl(packageName) { - return "\n * https://www.npmjs.com/package/".concat(packageName, "\n\n"); -} -function showGitHubIssueUrl(repo, query) { - return ("Please check to see if there's already an issue in the ".concat(repo, " repo:\n\n") + - " * ".concat(gitHubIssueUrl(repo, query), "\n\n") + - "If not, please open an issue and we'll take a look. (Or you can send a PR!)\n\n"); -} -function showPackageUpdateInstructions(packageName, repo, query) { - return ("Please try updating ".concat(packageName, " to the latest version:\n\n") + - " $ yarn upgrade ".concat(packageName, "\n\n") + - 'Or:\n\n' + - " $ npm update ".concat(packageName, "\n\n") + - "If that doesn't work, ".concat(packageName, " needs to be fixed to support the latest version.\n") + - (repo - ? showGitHubIssueUrl(repo, query) - : showNpmPackageUrl(packageName))); -} -function throwUnexpectedConfigError(_a) { - var message = _a.message, packageName = _a.packageName, repo = _a.githubRepo, query = _a.githubIssueQuery; - throw new Error("".concat(message, "\n\n") + - 'This error probably occurred because you updated react-scripts or craco. ' + - (packageName - ? showPackageUpdateInstructions(packageName, repo, query) - : 'You will need to update this plugin to work with the latest version.\n\n') + - 'You might also want to look for related issues in the ' + - 'craco and create-react-app repos:\n\n' + - " * ".concat(gitHubIssueUrl('sharegate/craco', query), "\n") + - " * ".concat(gitHubIssueUrl('facebook/create-react-app', query), "\n")); -} -exports.throwUnexpectedConfigError = throwUnexpectedConfigError; diff --git a/dist/lib/user-config-utils.d.ts b/dist/lib/user-config-utils.d.ts deleted file mode 100644 index 5ed12ef1..00000000 --- a/dist/lib/user-config-utils.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function when(condition: boolean, fn: () => T, unmetValue: T): T; -export declare function whenDev(fn: () => T, unmetValue: T): T; -export declare function whenProd(fn: () => T, unmetValue: T): T; -export declare function whenTest(fn: () => T, unmetValue: T): T; diff --git a/dist/lib/user-config-utils.js b/dist/lib/user-config-utils.js deleted file mode 100644 index c66cceae..00000000 --- a/dist/lib/user-config-utils.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.whenTest = exports.whenProd = exports.whenDev = exports.when = void 0; -function when(condition, fn, unmetValue) { - if (condition) { - return fn(); - } - return unmetValue; -} -exports.when = when; -function whenDev(fn, unmetValue) { - return when(process.env.NODE_ENV === 'development', fn, unmetValue); -} -exports.whenDev = whenDev; -function whenProd(fn, unmetValue) { - return when(process.env.NODE_ENV === 'production', fn, unmetValue); -} -exports.whenProd = whenProd; -function whenTest(fn, unmetValue) { - return when(process.env.NODE_ENV === 'test', fn, unmetValue); -} -exports.whenTest = whenTest; diff --git a/dist/lib/utils.d.ts b/dist/lib/utils.d.ts deleted file mode 100644 index 307d2440..00000000 --- a/dist/lib/utils.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare function isFunction(value: any): value is Function; -export declare function isArray(value: any): value is Array; -export declare function isString(value: any): value is string; -export declare function isBoolean(value: any): value is boolean; -export declare function deepMergeWithArray(dest: any, ...src: any): any; diff --git a/dist/lib/utils.js b/dist/lib/utils.js deleted file mode 100644 index 141b1ef3..00000000 --- a/dist/lib/utils.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.deepMergeWithArray = exports.isBoolean = exports.isString = exports.isArray = exports.isFunction = void 0; -var lodash_1 = require("lodash"); -function isFunction(value) { - return typeof value === 'function'; -} -exports.isFunction = isFunction; -function isArray(value) { - return Array.isArray(value); -} -exports.isArray = isArray; -function isString(value) { - return typeof value === 'string'; -} -exports.isString = isString; -function isBoolean(value) { - return typeof value === 'boolean'; -} -exports.isBoolean = isBoolean; -function deepMergeWithArray(dest) { - var src = []; - for (var _i = 1; _i < arguments.length; _i++) { - src[_i - 1] = arguments[_i]; - } - return lodash_1.mergeWith.apply(void 0, __spreadArray(__spreadArray([dest], __read(src), false), [function (x, y) { - if (isArray(x)) { - return x.concat(y); - } - }], false)); -} -exports.deepMergeWithArray = deepMergeWithArray; diff --git a/dist/lib/validate-cra-version.d.ts b/dist/lib/validate-cra-version.d.ts deleted file mode 100644 index 78d83c89..00000000 --- a/dist/lib/validate-cra-version.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { CracoConfig } from '../types/config'; -export declare function validateCraVersion(cracoConfig: CracoConfig): void; diff --git a/dist/lib/validate-cra-version.js b/dist/lib/validate-cra-version.js deleted file mode 100644 index 61a52c0f..00000000 --- a/dist/lib/validate-cra-version.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.validateCraVersion = void 0; -var cra_1 = require("../lib/cra"); -function validateCraVersion(cracoConfig) { - var _a = (0, cra_1.getReactScriptVersion)(cracoConfig), isSupported = _a.isSupported, version = _a.version; - if (!isSupported) { - throw new Error("Your current version of react-scripts(".concat(version, ") is not supported by this version of CRACO. Please try updating react-scripts to the latest version:\n\n") + - " $ yarn upgrade react-scripts\n\n" + - 'Or:\n\n' + - " $ npm update react-scripts\n\n" + - "If that doesn't work or if you can't, refer to the following table to choose the right version of CRACO.\n" + - 'https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#backward-compatibility'); - } -} -exports.validateCraVersion = validateCraVersion; diff --git a/dist/lib/webpack-plugins.d.ts b/dist/lib/webpack-plugins.d.ts deleted file mode 100644 index d5b6fbaa..00000000 --- a/dist/lib/webpack-plugins.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Configuration as WebpackConfig } from 'webpack'; -export declare function pluginByName(targetPluginName: string): (plugin: any) => boolean; -export declare function getPlugin(webpackConfig: WebpackConfig, matcher: (value: any, index?: number, obj?: any[]) => boolean): { - isFound: boolean; - match: import("webpack").WebpackPluginInstance | ((this: import("webpack").Compiler, compiler: import("webpack").Compiler) => void) | undefined; -}; -export declare function addPlugins(webpackConfig: WebpackConfig, webpackPlugins: any[]): void; -export declare function removePlugins(webpackConfig: WebpackConfig, matcher: (value: any, index?: number, array?: any[]) => boolean): { - hasRemovedAny: boolean; - removedCount: number; -}; diff --git a/dist/lib/webpack-plugins.js b/dist/lib/webpack-plugins.js deleted file mode 100644 index ccc2f520..00000000 --- a/dist/lib/webpack-plugins.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.removePlugins = exports.addPlugins = exports.getPlugin = exports.pluginByName = void 0; -function pluginByName(targetPluginName) { - return function (plugin) { - return plugin.constructor.name === targetPluginName; - }; -} -exports.pluginByName = pluginByName; -function getPlugin(webpackConfig, matcher) { - var _a; - var matchingPlugin = (_a = webpackConfig.plugins) === null || _a === void 0 ? void 0 : _a.find(matcher); - return { - isFound: matchingPlugin !== undefined, - match: matchingPlugin, - }; -} -exports.getPlugin = getPlugin; -function addPlugins(webpackConfig, webpackPlugins) { - var e_1, _a; - var prependPlugins = []; - var appendPlugins = []; - try { - for (var webpackPlugins_1 = __values(webpackPlugins), webpackPlugins_1_1 = webpackPlugins_1.next(); !webpackPlugins_1_1.done; webpackPlugins_1_1 = webpackPlugins_1.next()) { - var webpackPlugin = webpackPlugins_1_1.value; - if (Array.isArray(webpackPlugin)) { - var _b = __read(webpackPlugin, 2), plugin = _b[0], order = _b[1]; - if (order === 'append') { - appendPlugins.push(plugin); - } - else { - // Existing behaviour is to prepend - prependPlugins.push(plugin); - } - continue; - } - prependPlugins.push(webpackPlugin); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (webpackPlugins_1_1 && !webpackPlugins_1_1.done && (_a = webpackPlugins_1.return)) _a.call(webpackPlugins_1); - } - finally { if (e_1) throw e_1.error; } - } - webpackConfig.plugins = __spreadArray(__spreadArray(__spreadArray([], __read(prependPlugins), false), __read(webpackConfig.plugins), false), __read(appendPlugins), false); -} -exports.addPlugins = addPlugins; -function removePlugins(webpackConfig, matcher) { - var _a, _b, _c, _d, _e; - var prevCount = (_b = (_a = webpackConfig.plugins) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0; - webpackConfig.plugins = (_c = webpackConfig.plugins) === null || _c === void 0 ? void 0 : _c.filter(function (x, i, a) { return !matcher(x, i, a); }); - var removedPluginsCount = prevCount - ((_e = (_d = webpackConfig.plugins) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0); - return { - hasRemovedAny: removedPluginsCount > 0, - removedCount: removedPluginsCount, - }; -} -exports.removePlugins = removePlugins; diff --git a/dist/scripts/build.d.ts b/dist/scripts/build.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/dist/scripts/build.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/dist/scripts/build.js b/dist/scripts/build.js deleted file mode 100644 index b3181a74..00000000 --- a/dist/scripts/build.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -process.env.NODE_ENV = 'production'; -var args_1 = require("../lib/args"); -// Make sure this is called before "paths" is imported. -(0, args_1.findArgsFromCli)(); -var config_1 = require("../lib/config"); -var cra_1 = require("../lib/cra"); -var override_1 = require("../lib/features/webpack/override"); -var logger_1 = require("../lib/logger"); -var validate_cra_version_1 = require("../lib/validate-cra-version"); -(0, logger_1.log)('Override started with arguments: ', process.argv); -(0, logger_1.log)('For environment: ', process.env.NODE_ENV); -var context = { - env: process.env.NODE_ENV, -}; -(0, config_1.loadCracoConfigAsync)(context).then(function (cracoConfig) { - (0, validate_cra_version_1.validateCraVersion)(cracoConfig); - context.paths = (0, cra_1.getCraPaths)(cracoConfig); - (0, override_1.overrideWebpackProd)(cracoConfig, context); - (0, cra_1.build)(cracoConfig); -}); diff --git a/dist/scripts/start.d.ts b/dist/scripts/start.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/dist/scripts/start.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/dist/scripts/start.js b/dist/scripts/start.js deleted file mode 100644 index d516ebdf..00000000 --- a/dist/scripts/start.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -process.env.NODE_ENV = process.env.NODE_ENV || 'development'; -var args_1 = require("../lib/args"); -// Make sure this is called before "paths" is imported. -(0, args_1.findArgsFromCli)(); -var config_1 = require("../lib/config"); -var cra_1 = require("../lib/cra"); -var override_1 = require("../lib/features/dev-server/override"); -var override_2 = require("../lib/features/webpack/override"); -var logger_1 = require("../lib/logger"); -var validate_cra_version_1 = require("../lib/validate-cra-version"); -(0, logger_1.log)('Override started with arguments: ', process.argv); -(0, logger_1.log)('For environment: ', process.env.NODE_ENV); -var context = { - env: process.env.NODE_ENV, -}; -(0, config_1.loadCracoConfigAsync)(context).then(function (cracoConfig) { - (0, validate_cra_version_1.validateCraVersion)(cracoConfig); - context.paths = (0, cra_1.getCraPaths)(cracoConfig); - (0, override_2.overrideWebpackDev)(cracoConfig, context); - (0, override_1.overrideDevServer)(cracoConfig, context); - (0, cra_1.start)(cracoConfig); -}); diff --git a/dist/scripts/test.d.ts b/dist/scripts/test.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/dist/scripts/test.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/dist/scripts/test.js b/dist/scripts/test.js deleted file mode 100644 index 47452aa5..00000000 --- a/dist/scripts/test.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -process.env.NODE_ENV = process.env.NODE_ENV || 'test'; -var args_1 = require("../lib/args"); -// Make sure this is called before "paths" is imported. -(0, args_1.findArgsFromCli)(); -var config_1 = require("../lib/config"); -var cra_1 = require("../lib/cra"); -var override_1 = require("../lib/features/jest/override"); -var logger_1 = require("../lib/logger"); -var validate_cra_version_1 = require("../lib/validate-cra-version"); -(0, logger_1.log)('Override started with arguments: ', process.argv); -(0, logger_1.log)('For environment: ', process.env.NODE_ENV); -var context = { - env: process.env.NODE_ENV, -}; -(0, config_1.loadCracoConfigAsync)(context).then(function (cracoConfig) { - (0, validate_cra_version_1.validateCraVersion)(cracoConfig); - context.paths = (0, cra_1.getCraPaths)(cracoConfig); - (0, override_1.overrideJest)(cracoConfig, context); - (0, cra_1.test)(cracoConfig); -}); diff --git a/dist/types/args.d.ts b/dist/types/args.d.ts deleted file mode 100644 index 67c26a5d..00000000 --- a/dist/types/args.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface CliArgs { - [key: string]: string | boolean; -} -export interface CliArgSpec { - [key: string]: { - arg: string; - value: boolean; - }; -} diff --git a/dist/types/args.js b/dist/types/args.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/args.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/types/asset-modules.d.ts b/dist/types/asset-modules.d.ts deleted file mode 100644 index 54e9af7f..00000000 --- a/dist/types/asset-modules.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { RuleSetRule } from 'webpack'; -export declare type AssetModuleType = 'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/sync' | 'webassembly/async' | 'asset' | 'asset/source' | 'asset/resource' | 'asset/inline'; -export declare type AssetModuleMatcher = (rule: RuleSetRule) => boolean; -export interface AssetModule { - rule: RuleSetRule; - index: number; -} diff --git a/dist/types/asset-modules.js b/dist/types/asset-modules.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/asset-modules.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/types/config.d.ts b/dist/types/config.d.ts deleted file mode 100644 index 820eaebc..00000000 --- a/dist/types/config.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { TransformOptions } from '@babel/core'; -import type { Options as AutoprefixerOptions } from 'autoprefixer'; -import type { Linter } from 'eslint'; -import type { PluginOptions } from 'eslint-webpack-plugin/types/options'; -import type { Configuration as WebpackConfig, WebpackPluginInstance } from 'webpack'; -import type { Configuration as DevServerConfig } from 'webpack-dev-server'; -import type { BaseContext, DevServerContext, JestContext, WebpackContext } from './context'; -import type { CracoPlugin } from './plugins'; -import type { Config as JestConfig } from '@jest/types'; -export declare type Configure = Config | ((config: Config, context: Context) => Config); -export interface CracoStyleConfig { - modules?: { - localIdentName?: string; - }; - css?: { - loaderOptions?: Configure; - }; - sass?: { - loaderOptions?: Configure; - }; - postcss?: { - mode?: 'extends' | 'file'; - plugins?: any[] | ((plugins: any[]) => any[]); - env?: { - autoprefixer?: AutoprefixerOptions; - stage?: 0 | 1 | 2 | 3 | 4 | false; - features?: { - [featureId: string]: any; - }; - }; - loaderOptions?: Configure; - }; -} -export interface CracoBabelConfig { - presets?: any[]; - plugins?: any[]; - loaderOptions?: Configure; -} -export interface CracoEsLintConfig { - enable?: boolean; - mode?: 'extends' | 'file'; - configure?: Configure; - pluginOptions?: Configure; -} -export declare type WebpackAlias = { - [alias: string]: string; -}; -export declare type AddWebpackPlugins = (WebpackPluginInstance | [WebpackPluginInstance, 'append' | 'prepend'])[]; -export interface CracoWebpackConfig { - alias?: WebpackAlias; - plugins?: { - add?: AddWebpackPlugins; - remove?: string[]; - }; - configure?: Configure; -} -export declare type CracoDevServerConfig = Configure; -export interface CracoJestConfig { - babel?: { - addPresets?: boolean; - addPlugins?: boolean; - }; - configure?: Configure; -} -export interface CracoTypeScriptConfig { - enableTypeChecking?: boolean; -} -export interface CracoPluginDefinition { - plugin: CracoPlugin; - options?: Options; -} -export interface CracoConfig { - reactScriptsVersion?: string; - style?: CracoStyleConfig; - eslint?: CracoEsLintConfig; - babel?: CracoBabelConfig; - jest?: CracoJestConfig; - typescript?: CracoTypeScriptConfig; - webpack?: CracoWebpackConfig; - devServer?: CracoDevServerConfig; - plugins?: CracoPluginDefinition[]; -} diff --git a/dist/types/config.js b/dist/types/config.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/config.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/types/context.d.ts b/dist/types/context.d.ts deleted file mode 100644 index b4dda53b..00000000 --- a/dist/types/context.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { ProxyConfigArray } from 'webpack-dev-server'; -export interface CraPaths { - dotenv: string; - appPath: string; - appBuild: string; - appPublic: string; - appHtml: string; - appIndexJs: string; - appPackageJson: string; - appSrc: string; - appTsConfig: string; - appJsConfig: string; - yarnLockFile: string; - testsSetup: string; - proxySetup: string; - appNodeModules: string; - swSrc: string; - publicUrlOrPath: string; - ownPath: string; - ownNodeModules: string; - appTypeDeclarations: string; - ownTypeDeclarations: string; - moduleFileExtensions: string[]; -} -export interface BaseContext { - env?: string; - paths?: CraPaths; -} -export declare type WebpackContext = BaseContext; -export interface DevServerContext extends BaseContext { - proxy?: ProxyConfigArray; - allowedHost?: string; -} -export interface JestContext extends BaseContext { - resolve?: (id: string) => string; - rootDir?: string; -} diff --git a/dist/types/context.js b/dist/types/context.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/context.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/types/loaders.d.ts b/dist/types/loaders.d.ts deleted file mode 100644 index 58bc5c04..00000000 --- a/dist/types/loaders.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { RuleSetRule, RuleSetUseItem } from 'webpack'; -export declare type Rule = RuleSetRule | undefined; -export declare type Rules = Rule[] | undefined; -export declare type LoaderMatcher = (rule: RuleSetRule | RuleSetUseItem) => boolean; -export interface Loader { - loader: Rule; - parent: Rules; - index: number; -} -export declare type CompleteLoader = Loader & { - loader: RuleSetRule; -}; diff --git a/dist/types/loaders.js b/dist/types/loaders.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/loaders.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/types/plugin-utils.d.ts b/dist/types/plugin-utils.d.ts deleted file mode 100644 index d5d9bdff..00000000 --- a/dist/types/plugin-utils.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface ConfigError { - message: string; - packageName?: string; - githubRepo?: string; - githubIssueQuery?: string; -} diff --git a/dist/types/plugin-utils.js b/dist/types/plugin-utils.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/plugin-utils.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/types/plugins.d.ts b/dist/types/plugins.d.ts deleted file mode 100644 index a0beccfd..00000000 --- a/dist/types/plugins.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { CracoConfig } from './config'; -import type { Configuration as DevServerConfig } from 'webpack-dev-server'; -import type { Config as JestConfig } from '@jest/types'; -import type { Configuration as WebpackConfig } from 'webpack'; -import type { BaseContext, DevServerContext, JestContext, WebpackContext } from './context'; -export declare type PluginOptions = any; -export interface CracoConfigOverride { - cracoConfig: CracoConfig; - pluginOptions: PluginOptions; - context: BaseContext; -} -export interface WebpackConfigOverride { - webpackConfig: WebpackConfig; - cracoConfig: CracoConfig; - pluginOptions: PluginOptions; - context: WebpackContext; -} -export interface DevServerConfigOverride { - devServerConfig: DevServerConfig; - cracoConfig: CracoConfig; - pluginOptions: PluginOptions; - context: DevServerContext; -} -export interface JestConfigOverride { - jestConfig: JestConfig.InitialOptions; - cracoConfig: CracoConfig; - pluginOptions: PluginOptions; - context: JestContext; -} -export interface CracoPlugin { - overrideCracoConfig?: (cracoConfigOverride: CracoConfigOverride) => CracoConfig; - overrideWebpackConfig?: (webpackConfigOverride: WebpackConfigOverride) => WebpackConfig; - overrideDevServerConfig?: (devServerConfigOverride: DevServerConfigOverride) => DevServerConfig; - overrideJestConfig?: (jestConfigOverride: JestConfigOverride) => JestConfig.InitialOptions; -} diff --git a/dist/types/plugins.js b/dist/types/plugins.js deleted file mode 100644 index c8ad2e54..00000000 --- a/dist/types/plugins.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true });