@reactunity/scripts 0.9.0 → 0.9.1

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.
package/config/env.js CHANGED
@@ -40,7 +40,7 @@ const dotenvFiles = [
40
40
  // https://github.com/motdotla/dotenv-expand
41
41
  dotenvFiles.forEach(dotenvFile => {
42
42
  if (fs.existsSync(dotenvFile)) {
43
- require('dotenv-expand')(
43
+ require('dotenv-expand').expand(
44
44
  require('dotenv').config({
45
45
  path: dotenvFile,
46
46
  })
package/config/paths.js CHANGED
@@ -73,6 +73,7 @@ module.exports = {
73
73
  yarnLockFile: resolveApp('yarn.lock'),
74
74
  testsSetup: resolveModule(resolveApp, 'src/setupTests'),
75
75
  proxySetup: resolveApp('src/setupProxy.js'),
76
+ webpackSetup: resolveApp('webpack.config.js'),
76
77
  appNodeModules: resolveApp('node_modules'),
77
78
  appWebpackCache: resolveApp('node_modules/.cache'),
78
79
  appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
@@ -98,6 +99,7 @@ module.exports = {
98
99
  yarnLockFile: resolveApp('yarn.lock'),
99
100
  testsSetup: resolveModule(resolveApp, 'src/setupTests'),
100
101
  proxySetup: resolveApp('src/setupProxy.js'),
102
+ webpackSetup: resolveApp('webpack.config.js'),
101
103
  appNodeModules: resolveApp('node_modules'),
102
104
  appWebpackCache: resolveApp('node_modules/.cache'),
103
105
  appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
@@ -136,6 +138,7 @@ if (
136
138
  yarnLockFile: resolveOwn(`${templatePath}/yarn.lock`),
137
139
  testsSetup: resolveModule(resolveOwn, `${templatePath}/src/setupTests`),
138
140
  proxySetup: resolveOwn(`${templatePath}/src/setupProxy.js`),
141
+ webpackSetup: resolveApp(`${templatePath}/webpack.config.js`),
139
142
  appNodeModules: resolveOwn('node_modules'),
140
143
  appWebpackCache: resolveOwn('node_modules/.cache'),
141
144
  appTsBuildInfoFile: resolveOwn('node_modules/.cache/tsconfig.tsbuildinfo'),
@@ -82,7 +82,7 @@ const sassModuleRegex = /\.module\.(scss|sass)$/;
82
82
 
83
83
  // This is the production and development configuration.
84
84
  // It is focused on developer experience, fast rebuilds, and a minimal bundle.
85
- module.exports = function (webpackEnv) {
85
+ const baseConfigFactory = function (webpackEnv) {
86
86
  const isEnvDevelopment = webpackEnv === 'development';
87
87
  const isEnvProduction = webpackEnv === 'production';
88
88
  const shouldExtractCss = isEnvProduction && extractCss;
@@ -282,6 +282,9 @@ module.exports = function (webpackEnv) {
282
282
  'react-dom$': 'react-dom/profiling',
283
283
  'scheduler/tracing': 'scheduler/tracing-profiling',
284
284
  }),
285
+ // Allows replacing react-dom with @reactunity/renderer to support some functionality like `unstable_batchedUpdates`
286
+ 'react-dom': '@reactunity/renderer',
287
+
285
288
  ...(modules.webpackAliases || {}),
286
289
  },
287
290
  plugins: [
@@ -650,3 +653,21 @@ module.exports = function (webpackEnv) {
650
653
  performance: false,
651
654
  };
652
655
  };
656
+
657
+ module.exports = function (webpackEnv) {
658
+ const baseConfig = baseConfigFactory(webpackEnv);
659
+
660
+ if (fs.existsSync(paths.webpackSetup)) {
661
+ const customSetup = require(paths.webpackSetup);
662
+
663
+ console.log(`Using custom webpack config found in '${paths.webpackSetup}'`);
664
+
665
+ if (typeof customSetup !== 'function') {
666
+ throw new Error('Custom webpack config file must export a function that accepts `env` as first parameter and `defaultConfig` as second');
667
+ }
668
+
669
+ return customSetup(webpackEnv, baseConfig);
670
+ }
671
+
672
+ return baseConfig;
673
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactunity/scripts",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Configuration and scripts for React Unity.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,14 +44,14 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "@babel/core": "^7.16.7",
48
- "@babel/eslint-parser": "^7.16.5",
47
+ "@babel/core": "^7.17.0",
48
+ "@babel/eslint-parser": "^7.17.0",
49
49
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
50
- "@types/react": "^17.0.38",
50
+ "@types/react": "^17.0.39",
51
51
  "@types/webpack-env": "^1.16.3",
52
- "@typescript-eslint/eslint-plugin": "^5.9.1",
53
- "@typescript-eslint/parser": "^5.9.1",
54
- "babel-jest": "^27.4.6",
52
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
53
+ "@typescript-eslint/parser": "^5.10.2",
54
+ "babel-jest": "^27.5.0",
55
55
  "babel-loader": "^8.2.3",
56
56
  "babel-plugin-named-asset-import": "^0.3.8",
57
57
  "babel-preset-react-app": "^10.0.1",
@@ -59,56 +59,55 @@
59
59
  "camelcase": "^6.3.0",
60
60
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
61
61
  "confusing-browser-globals": "^1.0.11",
62
- "css-loader": "^6.5.1",
63
- "dotenv": "^11.0.0",
64
- "dotenv-expand": "^5.1.0",
65
- "eslint": "^8.6.0",
62
+ "css-loader": "^6.6.0",
63
+ "dotenv": "^16.0.0",
64
+ "dotenv-expand": "^8.0.1",
65
+ "eslint": "^8.8.0",
66
66
  "eslint-plugin-import": "^2.25.4",
67
- "eslint-plugin-jest": "^25.3.4",
67
+ "eslint-plugin-jest": "^26.0.0",
68
68
  "eslint-plugin-react": "^7.28.0",
69
69
  "eslint-plugin-react-hooks": "^4.3.0",
70
- "eslint-plugin-testing-library": "^5.0.3",
70
+ "eslint-plugin-testing-library": "^5.0.5",
71
71
  "eslint-webpack-plugin": "^3.1.1",
72
72
  "file-loader": "^6.2.0",
73
73
  "fs-extra": "^10.0.0",
74
74
  "identity-obj-proxy": "^3.0.0",
75
- "jest": "^27.4.7",
76
- "jest-resolve": "^27.4.6",
75
+ "jest": "^27.5.0",
76
+ "jest-resolve": "^27.5.0",
77
77
  "jest-watch-typeahead": "^1.0.0",
78
- "mini-css-extract-plugin": "^2.4.7",
78
+ "mini-css-extract-plugin": "^2.5.3",
79
79
  "null-loader": "^4.0.1",
80
- "postcss": "^8.4.5",
80
+ "postcss": "^8.4.6",
81
81
  "postcss-loader": "^6.2.1",
82
82
  "prompts": "^2.4.2",
83
83
  "raw-loader": "^4.0.2",
84
84
  "react-app-polyfill": "^3.0.0",
85
85
  "react-dev-utils": "^12.0.0",
86
86
  "react-refresh": "^0.11.0",
87
- "resolve": "^1.21.0",
88
- "resolve-url-loader": "^4.0.0",
89
- "sass": "^1.48.0",
87
+ "resolve": "^1.22.0",
88
+ "resolve-url-loader": "^5.0.0",
89
+ "sass": "^1.49.7",
90
90
  "sass-loader": "^12.4.0",
91
91
  "semver": "^7.3.5",
92
92
  "source-map-loader": "^3.0.1",
93
93
  "style-loader": "^3.3.1",
94
- "tailwindcss": "^3.0.13",
95
- "terser-webpack-plugin": "^5.3.0",
94
+ "tailwindcss": "^3.0.18",
95
+ "terser-webpack-plugin": "^5.3.1",
96
96
  "url-loader": "^4.1.1",
97
- "webpack": "^5.66.0",
98
- "webpack-dev-server": "^4.7.3",
97
+ "webpack": "^5.68.0",
98
+ "webpack-dev-server": "^4.7.4",
99
99
  "webpack-manifest-plugin": "^4.1.1"
100
100
  },
101
101
  "devDependencies": {
102
- "react": "^17.0.2",
103
- "typescript": "^4.5.4"
102
+ "typescript": "^4.5.5"
104
103
  },
105
104
  "optionalDependencies": {
106
105
  "fsevents": "^2.3.2"
107
106
  },
108
107
  "peerDependencies": {
109
- "@reactunity/renderer": "^0.8.0",
108
+ "@reactunity/renderer": "^0.9.0",
110
109
  "react": ">= 16",
111
- "typescript": "^4.5.4"
110
+ "typescript": "^4.5.5"
112
111
  },
113
112
  "peerDependenciesMeta": {
114
113
  "typescript": {
package/scripts/init.js CHANGED
@@ -312,13 +312,13 @@ module.exports = function (
312
312
  );
313
313
  }
314
314
 
315
- // Install react and react-dom for backward compatibility with old CRA cli
316
- // which doesn't install react and react-dom along with react-unity-scripts
315
+ // Install react and @reactunity/renderer for backward compatibility with old CRA cli
316
+ // which doesn't install react and @reactunity/renderer along with react-unity-scripts
317
317
  if (!isReactInstalled(appPackage)) {
318
- args = args.concat(['react', 'react-dom']);
318
+ args = args.concat(['react', '@reactunity/renderer']);
319
319
  }
320
320
 
321
- // Install template dependencies, and react and react-dom if missing.
321
+ // Install template dependencies, and react and @reactunity/renderer if missing.
322
322
  if ((!isReactInstalled(appPackage) || templateName) && args.length > 1) {
323
323
  console.log();
324
324
  console.log(`Installing template dependencies using ${command}...`);
@@ -412,6 +412,6 @@ function isReactInstalled(appPackage) {
412
412
 
413
413
  return (
414
414
  typeof dependencies.react !== 'undefined' &&
415
- typeof dependencies['react-dom'] !== 'undefined'
415
+ typeof dependencies['@reactunity/renderer'] !== 'undefined'
416
416
  );
417
417
  }
package/scripts/start.js CHANGED
@@ -47,7 +47,6 @@ const paths = require('../config/paths');
47
47
  const configFactory = require('../config/webpack.config');
48
48
  const createDevServerConfig = require('../config/webpackDevServer.config');
49
49
  const getClientEnvironment = require('../config/env');
50
- const react = require(require.resolve('react', { paths: [paths.appPath] }));
51
50
 
52
51
  const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
53
52
  const useYarn = fs.existsSync(paths.yarnLockFile);
@@ -134,14 +133,6 @@ checkBrowsers(paths.appPath, isInteractive)
134
133
  clearConsole();
135
134
  }
136
135
 
137
- if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
138
- console.log(
139
- chalk.yellow(
140
- `Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
141
- )
142
- );
143
- }
144
-
145
136
  console.log(chalk.cyan('Starting the development server...\n'));
146
137
  });
147
138