Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 681124b

Browse files
committed
fix(express-engine): schematics compatible with IIS Node and Azure App service
The problem is that the `interceptor.js` which is used by IIS Node will require the application files rather than executing it. https://github.com/tjanczuk/iisnode/blob/8657944f8803d84514c0c7ddd48c046aa68e6edf/src/scripts/interceptor.js#L210 Thus, the server `run` method will never get invoked. Closes #1447
1 parent c38b12a commit 681124b

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

integration/express-engine-ivy-prerender/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function run() {
5252
// The below code is to ensure that the server is run only when not requiring the bundle.
5353
declare const __non_webpack_require__: NodeRequire;
5454
const mainModule = __non_webpack_require__.main;
55-
if (mainModule && mainModule.filename === __filename) {
55+
const moduleFilename = mainModule && mainModule.filename || '';
56+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
5657
run();
5758
}
5859

integration/express-engine-ivy/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function run() {
5252
// The below code is to ensure that the server is run only when not requiring the bundle.
5353
declare const __non_webpack_require__: NodeRequire;
5454
const mainModule = __non_webpack_require__.main;
55-
if (mainModule && mainModule.filename === __filename) {
55+
const moduleFilename = mainModule && mainModule.filename || '';
56+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
5657
run();
5758
}
5859

integration/express-engine-ve/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function run() {
5252
// The below code is to ensure that the server is run only when not requiring the bundle.
5353
declare const __non_webpack_require__: NodeRequire;
5454
const mainModule = __non_webpack_require__.main;
55-
if (mainModule && mainModule.filename === __filename) {
55+
const moduleFilename = mainModule && mainModule.filename || '';
56+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
5657
run();
5758
}
5859

modules/express-engine/schematics/install/files/__serverFileName@stripTsExtension__.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function run() {
5252
// The below code is to ensure that the server is run only when not requiring the bundle.
5353
declare const __non_webpack_require__: NodeRequire;
5454
const mainModule = __non_webpack_require__.main;
55-
if (mainModule && mainModule.filename === __filename) {
55+
const moduleFilename = mainModule && mainModule.filename || '';
56+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
5657
run();
5758
}
5859

0 commit comments

Comments
 (0)