@evadata/react-scripts 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,137 @@
1
+ // @remove-on-eject-begin
2
+ /**
3
+ * Copyright (c) 2015-present, Facebook, Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ // @remove-on-eject-end
9
+ 'use strict';
10
+
11
+ const fs = require('fs');
12
+ const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
13
+ const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
14
+ const ignoredFiles = require('react-dev-utils/ignoredFiles');
15
+ const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
16
+ const paths = require('./paths');
17
+ const getHttpsConfig = require('./getHttpsConfig');
18
+
19
+ const host = process.env.HOST || '0.0.0.0';
20
+ const sockHost = process.env.WDS_SOCKET_HOST;
21
+ const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
22
+ const sockPort = process.env.WDS_SOCKET_PORT;
23
+
24
+ module.exports = function (proxy, allowedHost) {
25
+ const disableFirewall =
26
+ !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
27
+ const httpsOptions = getHttpsConfig();
28
+ return {
29
+ // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
30
+ // websites from potentially accessing local content through DNS rebinding:
31
+ // https://github.com/webpack/webpack-dev-server/issues/887
32
+ // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
33
+ // However, it made several existing use cases such as development in cloud
34
+ // environment or subdomains in development significantly more complicated:
35
+ // https://github.com/facebook/create-react-app/issues/2271
36
+ // https://github.com/facebook/create-react-app/issues/2233
37
+ // While we're investigating better solutions, for now we will take a
38
+ // compromise. Since our WDS configuration only serves files in the `public`
39
+ // folder we won't consider accessing them a vulnerability. However, if you
40
+ // use the `proxy` feature, it gets more dangerous because it can expose
41
+ // remote code execution vulnerabilities in backends like Django and Rails.
42
+ // So we will disable the host check normally, but enable it if you have
43
+ // specified the `proxy` setting. Finally, we let you override it if you
44
+ // really know what you're doing with a special environment variable.
45
+ // Note: ["localhost", ".localhost"] will support subdomains - but we might
46
+ // want to allow setting the allowedHosts manually for more complex setups
47
+ allowedHosts: disableFirewall ? 'all' : [allowedHost],
48
+ headers: {
49
+ 'Access-Control-Allow-Origin': '*',
50
+ 'Access-Control-Allow-Methods': '*',
51
+ 'Access-Control-Allow-Headers': '*'
52
+ },
53
+ // Enable gzip compression of generated files.
54
+ compress: true,
55
+ static: {
56
+ // By default WebpackDevServer serves physical files from current directory
57
+ // in addition to all the virtual build products that it serves from memory.
58
+ // This is confusing because those files won’t automatically be available in
59
+ // production build folder unless we copy them. However, copying the whole
60
+ // project directory is dangerous because we may expose sensitive files.
61
+ // Instead, we establish a convention that only files in `public` directory
62
+ // get served. Our build script will copy `public` into the `build` folder.
63
+ // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
64
+ // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
65
+ // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
66
+ // Note that we only recommend to use `public` folder as an escape hatch
67
+ // for files like `favicon.ico`, `manifest.json`, and libraries that are
68
+ // for some reason broken when imported through webpack. If you just want to
69
+ // use an image, put it in `src` and `import` it from JavaScript instead.
70
+ directory: paths.appPublic,
71
+ publicPath: [paths.publicUrlOrPath],
72
+ // By default files from `contentBase` will not trigger a page reload.
73
+ watch: {
74
+ // Reportedly, this avoids CPU overload on some systems.
75
+ // https://github.com/facebook/create-react-app/issues/293
76
+ // src/node_modules is not ignored to support absolute imports
77
+ // https://github.com/facebook/create-react-app/issues/1065
78
+ ignored: ignoredFiles(paths.appSrc)
79
+ }
80
+ },
81
+ client: {
82
+ webSocketURL: {
83
+ // Enable custom sockjs pathname for websocket connection to hot reloading server.
84
+ // Enable custom sockjs hostname, pathname and port for websocket connection
85
+ // to hot reloading server.
86
+ hostname: sockHost,
87
+ pathname: sockPath,
88
+ port: sockPort
89
+ },
90
+ overlay: {
91
+ errors: true,
92
+ warnings: false
93
+ }
94
+ },
95
+ devMiddleware: {
96
+ // It is important to tell WebpackDevServer to use the same "publicPath" path as
97
+ // we specified in the webpack config. When homepage is '.', default to serving
98
+ // from the root.
99
+ // remove last slash so user can land on `/test` instead of `/test/`
100
+ publicPath: paths.publicUrlOrPath.slice(0, -1)
101
+ },
102
+
103
+ server: typeof httpsOptions === 'object' ? {type: 'https', options: httpsOptions} : {type: httpsOptions ? 'https' : 'http'},
104
+ host,
105
+ historyApiFallback: {
106
+ // Paths with dots should still use the history fallback.
107
+ // See https://github.com/facebook/create-react-app/issues/387.
108
+ disableDotRule: true,
109
+ index: paths.publicUrlOrPath
110
+ },
111
+ // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
112
+ proxy,
113
+ setupMiddlewares: (middlewares, devServer) => {
114
+ // Keep `evalSourceMapMiddleware`
115
+ // middlewares before `redirectServedPath` otherwise will not have any effect
116
+ // This lets us fetch source contents from webpack for the error overlay
117
+ devServer.app.use(evalSourceMapMiddleware(devServer));
118
+
119
+ if (fs.existsSync(paths.proxySetup)) {
120
+ // This registers user provided middleware for proxy reasons
121
+ require(paths.proxySetup)(devServer.app);
122
+ }
123
+
124
+ // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
125
+ devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
126
+
127
+ // This service worker file is effectively a 'no-op' that will reset any
128
+ // previous service worker registered for the same host:port combination.
129
+ // We do this in development to avoid hitting the production cache if
130
+ // it used the same host and port.
131
+ // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
132
+ devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
133
+
134
+ return middlewares;
135
+ }
136
+ };
137
+ };
@@ -0,0 +1,71 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="react" />
3
+ /// <reference types="react-dom" />
4
+
5
+ declare namespace NodeJS {
6
+ interface ProcessEnv {
7
+ readonly NODE_ENV: 'development' | 'production' | 'test';
8
+ readonly PUBLIC_URL: string;
9
+ }
10
+ }
11
+
12
+ declare module '*.avif' {
13
+ const src: string;
14
+ export default src;
15
+ }
16
+
17
+ declare module '*.bmp' {
18
+ const src: string;
19
+ export default src;
20
+ }
21
+
22
+ declare module '*.gif' {
23
+ const src: string;
24
+ export default src;
25
+ }
26
+
27
+ declare module '*.jpg' {
28
+ const src: string;
29
+ export default src;
30
+ }
31
+
32
+ declare module '*.jpeg' {
33
+ const src: string;
34
+ export default src;
35
+ }
36
+
37
+ declare module '*.png' {
38
+ const src: string;
39
+ export default src;
40
+ }
41
+
42
+ declare module '*.webp' {
43
+ const src: string;
44
+ export default src;
45
+ }
46
+
47
+ declare module '*.svg' {
48
+ import * as React from 'react';
49
+
50
+ export const ReactComponent: React.FunctionComponent<React.SVGProps<
51
+ SVGSVGElement
52
+ > & { title?: string }>;
53
+
54
+ const src: string;
55
+ export default src;
56
+ }
57
+
58
+ declare module '*.module.css' {
59
+ const classes: { readonly [key: string]: string };
60
+ export default classes;
61
+ }
62
+
63
+ declare module '*.module.scss' {
64
+ const classes: { readonly [key: string]: string };
65
+ export default classes;
66
+ }
67
+
68
+ declare module '*.module.sass' {
69
+ const classes: { readonly [key: string]: string };
70
+ export default classes;
71
+ }
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@evadata/react-scripts",
3
+ "version": "5.0.2",
4
+ "description": "Configuration and scripts for Create React App.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/evadataprotectcode/react-scripts.git"
8
+ },
9
+ "license": "MIT",
10
+ "files": [
11
+ "bin",
12
+ "config",
13
+ "lib",
14
+ "scripts",
15
+ "template",
16
+ "template-typescript",
17
+ "utils"
18
+ ],
19
+ "bin": {
20
+ "react-scripts": "./bin/react-scripts.js"
21
+ },
22
+ "types": "./lib/react-app.d.ts",
23
+ "dependencies": {
24
+ "@babel/core": "^7.16.0",
25
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
26
+ "@svgr/webpack": "^8.1.0",
27
+ "babel-jest": "^27.4.2",
28
+ "babel-loader": "^8.2.3",
29
+ "babel-plugin-named-asset-import": "^0.3.8",
30
+ "babel-preset-react-app": "^10.0.1",
31
+ "bfj": "^7.0.2",
32
+ "browserslist": "^4.18.1",
33
+ "camelcase": "^6.2.1",
34
+ "case-sensitive-paths-webpack-plugin": "^2.4.0",
35
+ "css-loader": "^6.5.1",
36
+ "css-minimizer-webpack-plugin": "^3.2.0",
37
+ "dotenv": "^10.0.0",
38
+ "dotenv-expand": "^5.1.0",
39
+ "eslint": "^9.21.0",
40
+ "eslint-webpack-plugin": "^5.0.0",
41
+ "file-loader": "^6.2.0",
42
+ "fs-extra": "^10.0.0",
43
+ "html-webpack-plugin": "^5.5.0",
44
+ "identity-obj-proxy": "^3.0.0",
45
+ "jest": "^27.4.3",
46
+ "jest-resolve": "^27.4.2",
47
+ "jest-watch-typeahead": "^1.0.0",
48
+ "mini-css-extract-plugin": "^2.4.5",
49
+ "postcss": "^8.4.4",
50
+ "postcss-flexbugs-fixes": "^5.0.2",
51
+ "postcss-loader": "^6.2.1",
52
+ "postcss-normalize": "^10.0.1",
53
+ "postcss-preset-env": "^7.0.1",
54
+ "prompts": "^2.4.2",
55
+ "react-app-polyfill": "^3.0.0",
56
+ "react-dev-utils": "^12.0.1",
57
+ "react-refresh": "^0.11.0",
58
+ "resolve": "^1.20.0",
59
+ "resolve-url-loader": "^5.0.0",
60
+ "sass-loader": "^12.3.0",
61
+ "semver": "^7.3.5",
62
+ "source-map-loader": "^3.0.0",
63
+ "style-loader": "^3.3.1",
64
+ "tailwindcss": "^3.0.2",
65
+ "terser-webpack-plugin": "^5.2.5",
66
+ "webpack": "^5.64.4",
67
+ "webpack-dev-server": "^5.2.2",
68
+ "webpack-manifest-plugin": "^4.0.2",
69
+ "workbox-webpack-plugin": "^7.3.0"
70
+ },
71
+ "devDependencies": {
72
+ "react": "^18.0.0",
73
+ "react-dom": "^18.0.0"
74
+ },
75
+ "optionalDependencies": {
76
+ "fsevents": "^2.3.2"
77
+ },
78
+ "peerDependencies": {
79
+ "react": ">= 16",
80
+ "typescript": "^5.8.2"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "typescript": {
84
+ "optional": true
85
+ }
86
+ },
87
+ "browserslist": {
88
+ "production": [
89
+ ">0.2%",
90
+ "not dead",
91
+ "not op_mini all"
92
+ ],
93
+ "development": [
94
+ "last 1 chrome version",
95
+ "last 1 firefox version",
96
+ "last 1 safari version"
97
+ ]
98
+ },
99
+ "gitHead": "19fa58d527ae74f2b6baa0867463eea1d290f9a5"
100
+ }
@@ -0,0 +1,225 @@
1
+ // @remove-on-eject-begin
2
+ /**
3
+ * Copyright (c) 2015-present, Facebook, Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ // @remove-on-eject-end
9
+ 'use strict';
10
+
11
+ // Do this as the first thing so that any code reading it knows the right env.
12
+ process.env.BABEL_ENV = 'production';
13
+ process.env.NODE_ENV = 'production';
14
+
15
+ // Makes the script crash on unhandled rejections instead of silently
16
+ // ignoring them. In the future, promise rejections that are not handled will
17
+ // terminate the Node.js process with a non-zero exit code.
18
+ process.on('unhandledRejection', err => {
19
+ throw err;
20
+ });
21
+
22
+ // Ensure environment variables are read.
23
+ require('../config/env');
24
+
25
+ const path = require('path');
26
+ const chalk = require('react-dev-utils/chalk');
27
+ const fs = require('fs-extra');
28
+ const bfj = require('bfj');
29
+ const webpack = require('webpack');
30
+ const configFactory = require('../config/webpack.config');
31
+ const paths = require('../config/paths');
32
+ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
33
+ const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
34
+ const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
35
+ const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
36
+ const printBuildError = require('react-dev-utils/printBuildError');
37
+
38
+ const measureFileSizesBeforeBuild =
39
+ FileSizeReporter.measureFileSizesBeforeBuild;
40
+ const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
41
+ const useYarn = fs.existsSync(paths.yarnLockFile);
42
+
43
+ // These sizes are pretty large. We'll warn for bundles exceeding them.
44
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
45
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
46
+
47
+ const isInteractive = process.stdout.isTTY;
48
+
49
+ // Warn and crash if required files are missing
50
+ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
51
+ process.exit(1);
52
+ }
53
+
54
+ const argv = process.argv.slice(2);
55
+ const writeStatsJson = argv.indexOf('--stats') !== -1;
56
+
57
+ // Generate configuration
58
+ const config = configFactory('production');
59
+
60
+ // We require that you explicitly set browsers and do not fall back to
61
+ // browserslist defaults.
62
+ const { checkBrowsers } = require('react-dev-utils/browsersHelper');
63
+ checkBrowsers(paths.appPath, isInteractive)
64
+ .then(() => {
65
+ // First, read the current file sizes in build directory.
66
+ // This lets us display how much they changed later.
67
+ return measureFileSizesBeforeBuild(paths.appBuild);
68
+ })
69
+ .then(previousFileSizes => {
70
+ // Remove all content but keep the directory so that
71
+ // if you're in it, you don't end up in Trash
72
+ fs.emptyDirSync(paths.appBuild);
73
+ // Merge with the public folder
74
+ copyPublicFolder();
75
+ // Start the webpack build
76
+ return build(previousFileSizes);
77
+ })
78
+ .then(
79
+ ({ stats, previousFileSizes, warnings }) => {
80
+ if (warnings.length) {
81
+ console.log(chalk.yellow('Compiled with warnings.\n'));
82
+ console.log(warnings.join('\n\n'));
83
+ console.log(
84
+ '\nSearch for the ' +
85
+ chalk.underline(chalk.yellow('keywords')) +
86
+ ' to learn more about each warning.'
87
+ );
88
+ console.log(
89
+ 'To ignore, add ' +
90
+ chalk.cyan('// eslint-disable-next-line') +
91
+ ' to the line before.\n'
92
+ );
93
+ } else {
94
+ console.log(chalk.green('Compiled successfully.\n'));
95
+ }
96
+
97
+ console.log('File sizes after gzip:\n');
98
+ printFileSizesAfterBuild(
99
+ stats,
100
+ previousFileSizes,
101
+ paths.appBuild,
102
+ WARN_AFTER_BUNDLE_GZIP_SIZE,
103
+ WARN_AFTER_CHUNK_GZIP_SIZE
104
+ );
105
+ console.log();
106
+
107
+ const appPackage = require(paths.appPackageJson);
108
+ const publicUrl = paths.publicUrlOrPath;
109
+ const publicPath = config.output.publicPath;
110
+ const buildFolder = path.relative(process.cwd(), paths.appBuild);
111
+ printHostingInstructions(
112
+ appPackage,
113
+ publicUrl,
114
+ publicPath,
115
+ buildFolder,
116
+ useYarn
117
+ );
118
+ },
119
+ err => {
120
+ const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
121
+ if (tscCompileOnError) {
122
+ console.log(
123
+ chalk.yellow(
124
+ 'Compiled with the following type errors (you may want to check these before deploying your app):\n'
125
+ )
126
+ );
127
+ printBuildError(err);
128
+ } else {
129
+ console.log(chalk.red('Failed to compile.\n'));
130
+ printBuildError(err);
131
+ process.exit(1);
132
+ }
133
+ }
134
+ )
135
+ .catch(err => {
136
+ if (err && err.message) {
137
+ console.log(err.message);
138
+ }
139
+ process.exit(1);
140
+ });
141
+
142
+ // Create the production build and print the deployment instructions.
143
+ function build(previousFileSizes) {
144
+ console.log('Creating an optimized production build...');
145
+
146
+ const compiler = webpack(config);
147
+ return new Promise((resolve, reject) => {
148
+ compiler.run((err, stats) => {
149
+ let messages;
150
+ if (err) {
151
+ if (!err.message) {
152
+ return reject(err);
153
+ }
154
+
155
+ let errMessage = err.message;
156
+
157
+ // Add additional information for postcss errors
158
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
159
+ errMessage +=
160
+ '\nCompileError: Begins at CSS selector ' +
161
+ err['postcssNode'].selector;
162
+ }
163
+
164
+ messages = formatWebpackMessages({
165
+ errors: [errMessage],
166
+ warnings: []
167
+ });
168
+ } else {
169
+ messages = formatWebpackMessages(
170
+ stats.toJson({ all: false, warnings: true, errors: true })
171
+ );
172
+ }
173
+ if (messages.errors.length) {
174
+ // Only keep the first error. Others are often indicative
175
+ // of the same problem, but confuse the reader with noise.
176
+ if (messages.errors.length > 1) {
177
+ messages.errors.length = 1;
178
+ }
179
+ return reject(new Error(messages.errors.join('\n\n')));
180
+ }
181
+ if (
182
+ process.env.CI &&
183
+ (typeof process.env.CI !== 'string' ||
184
+ process.env.CI.toLowerCase() !== 'false') &&
185
+ messages.warnings.length
186
+ ) {
187
+ // Ignore sourcemap warnings in CI builds. See #8227 for more info.
188
+ const filteredWarnings = messages.warnings.filter(
189
+ w => !/Failed to parse source map/.test(w)
190
+ );
191
+ if (filteredWarnings.length) {
192
+ console.log(
193
+ chalk.yellow(
194
+ '\nTreating warnings as errors because process.env.CI = true.\n' +
195
+ 'Most CI servers set it automatically.\n'
196
+ )
197
+ );
198
+ return reject(new Error(filteredWarnings.join('\n\n')));
199
+ }
200
+ }
201
+
202
+ const resolveArgs = {
203
+ stats,
204
+ previousFileSizes,
205
+ warnings: messages.warnings
206
+ };
207
+
208
+ if (writeStatsJson) {
209
+ return bfj
210
+ .write(paths.appBuild + '/bundle-stats.json', stats.toJson())
211
+ .then(() => resolve(resolveArgs))
212
+ .catch(error => reject(new Error(error)));
213
+ }
214
+
215
+ return resolve(resolveArgs);
216
+ });
217
+ });
218
+ }
219
+
220
+ function copyPublicFolder() {
221
+ fs.copySync(paths.appPublic, paths.appBuild, {
222
+ dereference: true,
223
+ filter: file => file !== paths.appHtml
224
+ });
225
+ }