@commercetools-frontend/mc-scripts 21.0.0-rc.2 → 21.0.0-rc.7

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
  }
@@ -61,23 +61,22 @@ 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) => {
74
- response.statusCode = 400;
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) => {
76
+ response.statusCode = 404;
75
77
  response.setHeader('Content-Type', 'application/json');
76
- 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".`;
77
- const fakeApolloError = new Error(errorMessage);
78
78
  response.end(JSON.stringify({
79
- data: null,
80
- error: fakeApolloError
79
+ message: `This GraphQL endpoint is only available in production in the [Merchant Center Proxy Router](https://docs.commercetools.com/custom-applications/concepts/merchant-center-proxy-router). Please check that you are not calling this endpoint in development mode.`
81
80
  }));
82
81
  });
83
82
 
@@ -86,13 +85,15 @@ module.exports = ({
86
85
 
87
86
  // Handle login page for OIDC workflow when developing against a local MC API.
88
87
  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));
88
+ devServer.app.get('/login/authorize', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env));
90
89
  }
91
90
  } else {
92
- app.use('/login', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env)); // Intercept the /logout page and "remove" the auth cookie value
91
+ devServer.app.get('/login', devAuthentication.middlewares.createLoginMiddleware(applicationConfig.env)); // Intercept the /logout page and "remove" the auth cookie value
93
92
 
94
- app.use('/logout', devAuthentication.middlewares.createLogoutMiddleware(applicationConfig.env));
93
+ devServer.app.get('/logout', devAuthentication.middlewares.createLogoutMiddleware(applicationConfig.env));
95
94
  }
95
+
96
+ return middlewares;
96
97
  }
97
98
 
98
99
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/mc-scripts",
3
- "version": "21.0.0-rc.2",
3
+ "version": "21.0.0-rc.7",
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": {
@@ -28,11 +28,11 @@
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.7",
30
30
  "@babel/runtime-corejs3": "^7.16.8",
31
- "@commercetools-frontend/application-config": "21.0.0-rc.1",
31
+ "@commercetools-frontend/application-config": "21.0.0-rc.7",
32
32
  "@commercetools-frontend/assets": "21.0.0-rc.1",
33
- "@commercetools-frontend/babel-preset-mc-app": "21.0.0-rc.1",
33
+ "@commercetools-frontend/babel-preset-mc-app": "21.0.0-rc.7",
34
34
  "@commercetools-frontend/mc-dev-authentication": "21.0.0-rc.1",
35
- "@commercetools-frontend/mc-html-template": "21.0.0-rc.1",
35
+ "@commercetools-frontend/mc-html-template": "21.0.0-rc.7",
36
36
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
37
37
  "@svgr/webpack": "6.2.0",
38
38
  "autoprefixer": "10.4.2",