From ee44e2d41759b18d94c5b6a4725a43dabdb9ea84 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 27 Apr 2023 14:12:52 -0400 Subject: [PATCH 1/2] fix: update normalize-path to use ECMAScript compliant default import The `normalize-path` package was previously imported via a namespace import. However, the ECMAScript specification returns an exotic namespace object from namespace imports which can never be a function. As a result a namespace import can not be called. Since the import is directly called it must be imported As a default import to be ECMAScript compliant. TypeScript by default allows the non-compliant form even though it can result in runtime errors. The TypeScript `esModuleInterop` option (recommended by TypeScript) causes TypeScript to error on non-compliant usage and ensures the correct code is emitted so that the code can be executed and/or bundled in an ESM environment. --- src/app/shared/normalize-path.ts | 2 +- tsconfig.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/shared/normalize-path.ts b/src/app/shared/normalize-path.ts index 99594fff..12d7ff90 100644 --- a/src/app/shared/normalize-path.ts +++ b/src/app/shared/normalize-path.ts @@ -1,4 +1,4 @@ -import * as normalize from 'path-normalize'; +import normalize from 'path-normalize'; /** * Normalizes the given path by: diff --git a/tsconfig.json b/tsconfig.json index 203f6057..92a964f4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, + "esModuleInterop": true, "module": "es2020", "moduleResolution": "node", "importHelpers": true, From e455ebdb0ddb4040115dc1a8d96d33353d14f696 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 27 Apr 2023 14:17:37 -0400 Subject: [PATCH 2/2] build: enabled building the application with the ESM build system --- angular.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular.json b/angular.json index ecf00b9c..7a2e45c6 100644 --- a/angular.json +++ b/angular.json @@ -14,7 +14,7 @@ }, "architect": { "build": { - "builder": "@angular-devkit/build-angular:browser", + "builder": "@angular-devkit/build-angular:browser-esbuild", "options": { "sourceMap": true, "allowedCommonJsDependencies": ["moment", "path-normalize"], @@ -211,7 +211,7 @@ "prefix": "app", "architect": { "build": { - "builder": "@angular-devkit/build-angular:browser", + "builder": "@angular-devkit/build-angular:browser-esbuild", "options": { "outputPath": "dist/scenes", "index": "scenes/src/index.html",