@commercetools-frontend/mc-scripts 21.0.0-rc.0 → 21.0.0-rc.4

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.
@@ -102,17 +102,11 @@ function build(previousFileSizes) {
102
102
  warnings: []
103
103
  });
104
104
  } else {
105
- //TODO: Remove after 'react-dev-utils' natively supports webpack@5
106
- const rawMessages = stats.toJson({
105
+ messages = formatWebpackMessages(stats.toJson({
107
106
  all: false,
108
107
  warnings: true,
109
- errors: true,
110
- moduleTrace: false
111
- });
112
- messages = formatWebpackMessages({
113
- errors: rawMessages.errors.map(e => e.message),
114
- warnings: rawMessages.warnings.map(e => e.message)
115
- });
108
+ errors: true
109
+ }));
116
110
  }
117
111
 
118
112
  if (messages.errors.length) {
@@ -77,14 +77,9 @@ choosePort(HOST, DEFAULT_PORT).then(port => {
77
77
  port,
78
78
  publicPath: config.output.publicPath
79
79
  });
80
- const devServer = new WebpackDevServer(compiler, serverConfig); // Launch WebpackDevServer.
81
-
82
- devServer.listen(port, HOST, err => {
83
- if (err) {
84
- console.log(err);
85
- return;
86
- }
80
+ const devServer = new WebpackDevServer(serverConfig, compiler); // Launch WebpackDevServer.
87
81
 
82
+ devServer.startCallback(() => {
88
83
  if (isInteractive) {
89
84
  clearConsole();
90
85
  }
@@ -96,7 +96,15 @@ module.exports = function createWebpackConfigForDevelopment(options = {}) {
96
96
  // https://github.com/facebook/create-react-app/issues/290
97
97
  // `web` extension prefixes have been added for better support
98
98
  // for React Native Web.
99
- extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`)
99
+ extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`),
100
+ // NOTE: this is meant to be a temporary list of fallback/polyfills for certain
101
+ // nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
102
+ // however now it's not the case anymore.
103
+ // See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
104
+ fallback: {
105
+ url: require.resolve('url/'),
106
+ querystring: require.resolve('querystring-es3')
107
+ }
100
108
  },
101
109
  entry: {
102
110
  app: [require.resolve('./application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), // When using the experimental `react-refresh` integration,
@@ -138,7 +138,14 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
138
138
  // https://github.com/facebook/create-react-app/issues/290
139
139
  // `web` extension prefixes have been added for better support
140
140
  // for React Native Web.
141
- extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`)
141
+ extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].map(ext => `.${ext}`),
142
+ // NOTE: this is meant to be a temporary list of fallback/polyfills for certain
143
+ // nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
144
+ // however now it's not the case anymore.
145
+ // See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
146
+ fallback: {
147
+ querystring: require.resolve('querystring-es3')
148
+ }
142
149
  },
143
150
  // In production, we only want to load the polyfills and the app code.
144
151
  entry: {
@@ -61,16 +61,18 @@ module.exports = ({
61
61
 
62
62
  // Enable HTTPS if the HTTPS environment variable is set to 'true'
63
63
  // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
64
- onBeforeSetupMiddleware({
65
- app
66
- }) {
64
+ setupMiddlewares(middlewares, devServer) {
67
65
  var _applicationConfig$en, _applicationConfig$en2;
68
66
 
69
- app.set('views', devAuthentication.views);
70
- app.set('view engine', devAuthentication.config.viewEngine); // This lets us open files from the runtime error overlay.
67
+ if (!devServer) {
68
+ throw new Error('webpack-dev-server is not defined');
69
+ } // This lets us open files from the runtime error overlay.
71
70
 
72
- app.use(errorOverlayMiddleware());
73
- app.use('/api/graphql', (request, response) => {
71
+
72
+ middlewares.unshift(errorOverlayMiddleware());
73
+ devServer.app.set('views', devAuthentication.views);
74
+ devServer.app.set('view engine', devAuthentication.config.viewEngine);
75
+ devServer.app.post('/api/graphql', (request, response) => {
74
76
  response.statusCode = 400;
75
77
  response.setHeader('Content-Type', 'application/json');
76
78
  const errorMessage = `This GraphQL endpoint is not available in ${process.env.NODE_ENV} mode, as it's not necessary. The menu configuration is loaded from the file "menu.json" (more info at https://www.npmjs.com/package/@commercetools-frontend/application-shell). In case you do need to test things out, you can pass a "mcProxyApiUrl" to your application config (in the "additionalEnv" properties) and point it to the production environment, for example for GCP-EU use "https://mc.europe-west1.gcp.commercetools.com/api/graphql".`;
@@ -86,13 +88,15 @@ module.exports = ({
86
88
 
87
89
  // Handle login page for OIDC workflow when developing against a local MC API.
88
90
  if ((_applicationConfig$en3 = applicationConfig.env.__DEVELOPMENT__) !== null && _applicationConfig$en3 !== void 0 && (_applicationConfig$en4 = _applicationConfig$en3.oidc) !== null && _applicationConfig$en4 !== void 0 && _applicationConfig$en4.authorizeUrl.startsWith('http://localhost')) {
89
- app.use('/login/authorize', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env));
91
+ devServer.app.get('/login/authorize', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env));
90
92
  }
91
93
  } else {
92
- app.use('/login', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env)); // Intercept the /logout page and "remove" the auth cookie value
94
+ devServer.app.get('/login', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env)); // Intercept the /logout page and "remove" the auth cookie value
93
95
 
94
- app.use('/logout', devAuthentication.middlewares.createLogoutMiddleware(applicationConfig.env));
96
+ devServer.app.get('/logout', devAuthentication.middlewares.createLogoutMiddleware(applicationConfig.env));
95
97
  }
98
+
99
+ return middlewares;
96
100
  }
97
101
 
98
102
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/mc-scripts",
3
- "version": "21.0.0-rc.0",
3
+ "version": "21.0.0-rc.4",
4
4
  "description": "Configuration and scripts for developing a MC application",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -26,19 +26,19 @@
26
26
  "build:bundles:watch": "yarn build -w"
27
27
  },
28
28
  "dependencies": {
29
- "@babel/runtime": "7.16.7",
30
- "@babel/runtime-corejs3": "7.16.8",
31
- "@commercetools-frontend/application-config": "21.0.0-rc.0",
32
- "@commercetools-frontend/assets": "20.12.3",
33
- "@commercetools-frontend/babel-preset-mc-app": "21.0.0-rc.0",
34
- "@commercetools-frontend/mc-dev-authentication": "21.0.0-rc.0",
35
- "@commercetools-frontend/mc-html-template": "21.0.0-rc.0",
29
+ "@babel/runtime": "^7.16.7",
30
+ "@babel/runtime-corejs3": "^7.16.8",
31
+ "@commercetools-frontend/application-config": "21.0.0-rc.4",
32
+ "@commercetools-frontend/assets": "21.0.0-rc.1",
33
+ "@commercetools-frontend/babel-preset-mc-app": "21.0.0-rc.1",
34
+ "@commercetools-frontend/mc-dev-authentication": "21.0.0-rc.1",
35
+ "@commercetools-frontend/mc-html-template": "21.0.0-rc.4",
36
36
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
37
37
  "@svgr/webpack": "6.2.0",
38
38
  "autoprefixer": "10.4.2",
39
39
  "babel-loader": "8.2.3",
40
40
  "browserslist": "4.19.1",
41
- "core-js": "3.20.3",
41
+ "core-js": "^3.20.3",
42
42
  "css-loader": "5.2.7",
43
43
  "css-minimizer-webpack-plugin": "3.4.1",
44
44
  "dotenv": "10.0.0",
@@ -57,7 +57,8 @@
57
57
  "postcss-import": "14.0.2",
58
58
  "postcss-loader": "6.2.1",
59
59
  "postcss-reporter": "7.0.5",
60
- "react-dev-utils": "11.0.4",
60
+ "querystring-es3": "^0.2.1",
61
+ "react-dev-utils": "12.0.0",
61
62
  "react-refresh": "0.11.0",
62
63
  "serve-handler": "6.1.3",
63
64
  "shelljs": "0.8.5",
@@ -65,14 +66,15 @@
65
66
  "svg-url-loader": "7.1.1",
66
67
  "terser-webpack-plugin": "5.3.0",
67
68
  "thread-loader": "3.0.4",
69
+ "url": "^0.11.0",
68
70
  "webpack": "5.66.0",
69
71
  "webpack-bundle-analyzer": "4.5.0",
70
72
  "webpack-dev-server": "4.7.3",
71
73
  "webpackbar": "5.0.2"
72
74
  },
73
75
  "devDependencies": {
74
- "@babel/plugin-transform-runtime": "7.16.10",
75
- "@babel/preset-env": "7.16.11",
76
+ "@babel/plugin-transform-runtime": "^7.16.10",
77
+ "@babel/preset-env": "^7.16.11",
76
78
  "rimraf": "3.0.2"
77
79
  },
78
80
  "engines": {