@nrwl/next 14.5.6 → 14.5.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [14.5.6](https://github.com/nrwl/nx/compare/14.5.5...14.5.6) (2022-08-14)
6
+ ## [14.5.7](https://github.com/nrwl/nx/compare/14.5.6...14.5.7) (2022-08-17)
7
7
 
8
8
  **Note:** Version bump only for package @nrwl/next
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrwl/next",
3
- "version": "14.5.6",
3
+ "version": "14.5.7",
4
4
  "description": "When using Next.js in Nx, you get the out-of-the-box support for TypeScript, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.\n\nThe Next.js plugin contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/plugin-proposal-decorators": "^7.14.5",
37
- "@nrwl/cypress": "14.5.6",
38
- "@nrwl/devkit": "14.5.6",
39
- "@nrwl/jest": "14.5.6",
40
- "@nrwl/linter": "14.5.6",
41
- "@nrwl/react": "14.5.6",
42
- "@nrwl/web": "14.5.6",
43
- "@nrwl/workspace": "14.5.6",
37
+ "@nrwl/cypress": "14.5.7",
38
+ "@nrwl/devkit": "14.5.7",
39
+ "@nrwl/jest": "14.5.7",
40
+ "@nrwl/linter": "14.5.7",
41
+ "@nrwl/react": "14.5.7",
42
+ "@nrwl/web": "14.5.7",
43
+ "@nrwl/workspace": "14.5.7",
44
44
  "@svgr/webpack": "^6.1.2",
45
45
  "chalk": "4.1.0",
46
46
  "dotenv": "~10.0.0",
@@ -52,5 +52,5 @@
52
52
  "url-loader": "^4.1.1",
53
53
  "webpack-merge": "^5.8.0"
54
54
  },
55
- "gitHead": "608141ec7c3f8718419fc869f506196180e2bf2c"
55
+ "gitHead": "f8085d094993a3999b41dca787ecfef0f2be7b83"
56
56
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applicationSchematic = exports.applicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nrwl/devkit");
6
+ const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial");
6
7
  const normalize_options_1 = require("./lib/normalize-options");
7
8
  const add_cypress_1 = require("./lib/add-cypress");
8
9
  const add_jest_1 = require("./lib/add-jest");
@@ -14,7 +15,7 @@ const update_jest_config_1 = require("./lib/update-jest-config");
14
15
  const init_1 = require("../init/init");
15
16
  const styles_1 = require("../../utils/styles");
16
17
  const add_linting_1 = require("./lib/add-linting");
17
- const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial");
18
+ const custom_server_1 = require("../custom-server/custom-server");
18
19
  function applicationGenerator(host, schema) {
19
20
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
21
  const options = (0, normalize_options_1.normalizeOptions)(host, schema);
@@ -28,6 +29,12 @@ function applicationGenerator(host, schema) {
28
29
  (0, update_jest_config_1.updateJestConfig)(host, options);
29
30
  const styledTask = (0, styles_1.addStyleDependencies)(host, options.style);
30
31
  (0, set_defaults_1.setDefaults)(host, options);
32
+ if (options.customServer) {
33
+ yield (0, custom_server_1.customServerGenerator)(host, {
34
+ project: options.name,
35
+ compiler: options.swc ? 'swc' : 'tsc',
36
+ });
37
+ }
31
38
  if (!options.skipFormat) {
32
39
  yield (0, devkit_1.formatFiles)(host);
33
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../packages/next/src/gener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,EACR,UAAU,CACX,CAAC;IACJ,CAAC;CAAA;AA5BD,oDA4BC;AAEY,QAAA,oBAAoB,GAAG,IAAA,2BAAkB,EAAC,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/application/application.ts"],"names":[],"mappings":";;;;AAAA,yCAAqE;AACrE,2FAAqF;AAErF,+DAA2D;AAE3D,mDAA+C;AAC/C,6CAAyC;AACzC,mDAA+C;AAC/C,6EAAwE;AACxE,6EAAuE;AACvE,qDAAiD;AACjD,iEAA4D;AAC5D,uCAAiD;AACjD,+CAA0D;AAC1D,mDAA+C;AAC/C,kEAAuE;AAEvE,SAAsB,oBAAoB,CAAC,IAAU,EAAE,MAAc;;QACnE,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAiB,EAAC,IAAI,kCACxC,OAAO,KACV,UAAU,EAAE,IAAI,IAChB,CAAC;QACH,IAAA,iDAAsB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtC,IAAA,gDAAqB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrC,IAAA,wBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1B,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjD,IAAA,qCAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAA,0BAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3B,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,MAAM,IAAA,qCAAqB,EAAC,IAAI,EAAE;gBAChC,OAAO,EAAE,OAAO,CAAC,IAAI;gBACrB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;aACtC,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,sCAAgB,EACrB,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,CACX,CAAC;IACJ,CAAC;CAAA;AAnCD,oDAmCC;AAEY,QAAA,oBAAoB,GAAG,IAAA,2BAAkB,EAAC,oBAAoB,CAAC,CAAC"}
@@ -16,4 +16,5 @@ export interface Schema {
16
16
  setParserOptionsProject?: boolean;
17
17
  standaloneConfig?: boolean;
18
18
  swc?: boolean;
19
+ customServer?: boolean;
19
20
  }
@@ -119,6 +119,11 @@
119
119
  "description": "Enable the Rust-based compiler SWC to compile JS/TS files.",
120
120
  "type": "boolean",
121
121
  "default": true
122
+ },
123
+ "customServer": {
124
+ "description": "Use a custom Express server for the Next.js application.",
125
+ "type": "boolean",
126
+ "default": false
122
127
  }
123
128
  },
124
129
  "required": []
@@ -1,8 +1,13 @@
1
1
  /*
2
2
  * This is only a minimal custom server to get started.
3
- * You should customize this server with CORS and other security features.
3
+ * You may want to consider using Express or another server framework, and enable security features such as CORS.
4
+ *
5
+ * For more examples, see the Next.js repo:
6
+ * - Express: https://github.com/vercel/next.js/tree/canary/examples/custom-server-express
7
+ * - Hapi: https://github.com/vercel/next.js/tree/canary/examples/custom-server-hapi
4
8
  */
5
- import express from 'express';
9
+ import { createServer } from 'http';
10
+ import { parse } from 'url';
6
11
  import * as path from 'path';
7
12
  import next from 'next';
8
13
 
@@ -11,10 +16,9 @@ import next from 'next';
11
16
  // - The fallback `__dirname` is for production builds.
12
17
  // - Feel free to change this to suit your needs.
13
18
  const dir = process.env.NX_NEXT_DIR || path.join(__dirname, '..');
14
- const publicDir = process.env.NX_NEXT_PUBLIC_DIR || path.join(__dirname, '../public');
15
19
  const dev = process.env.NODE_ENV === 'development';
16
20
 
17
- // Express server options:
21
+ // HTTP Server options:
18
22
  // - Feel free to change this to suit your needs.
19
23
  const hostname = process.env.HOST || 'localhost';
20
24
  const port = process.env.PORT ? parseInt(process.env.PORT) : 4200;
@@ -25,28 +29,14 @@ async function main() {
25
29
 
26
30
  await nextApp.prepare();
27
31
 
28
- const expressApp = express();
29
-
30
- expressApp.get('/api', (req, res) => {
31
- res.send({ message: 'Welcome!' });
32
+ const server = createServer((req, res) => {
33
+ const parsedUrl = parse(req.url, true);
34
+ handle(req, res, parsedUrl);
32
35
  });
33
36
 
34
- // Serve static files from public folder.
35
- expressApp.use(express.static(publicDir));
36
-
37
- // Redirect requests to Next.js app.
38
- expressApp.all('*', (req, res) => {
39
- console.log('Forwarding request to Next.js: ', req.url);
40
- handle(req, res)
41
- });
37
+ server.listen(port, hostname);
42
38
 
43
- return new Promise<void>((resolve, reject) => {
44
- expressApp.on('error', (err) => reject(err));
45
- expressApp.listen(port, () => {
46
- console.log(`[ ready ] on http://${hostname}:${port}`)
47
- resolve();
48
- });
49
- });
39
+ console.log(`[ ready ] on http://${hostname}:${port}`)
50
40
  }
51
41
 
52
42
  main().catch((err) => {