Hi! 馃憢
Firstly, thanks for your work on this project! 馃檪
Today I used patch-package to patch @swimlane/ngx-datatable@23.0.1 for the project I'm working on.
Description of the Problem
When compiling an Angular application (specifically Angular 17+ using the modern esbuild/Vite application builder), the build fails with a fatal error: No matching export in "node_modules/@angular/core/fesm2022/core.mjs" for import "DOCUMENT".
This happens because DOCUMENT is currently being imported from @angular/core inside the package's ESM output, but the DOCUMENT token actually resides in @angular/common.
While Webpack-based builds in older Angular versions allowed this silently, the modern esbuild compiler strictly validates ESM exports and completely crashes when it cannot resolve the import, preventing the application from serving or building. Moving the DOCUMENT import to @angular/common resolves the build failure entirely.
Here is the diff that solved my problem:
diff --git a/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs b/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs
--- a/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs
+++ b/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs
@@ -1,5 +1,6 @@
import * as i0 from '@angular/core';
-import { EventEmitter, Directive, Input, Output, HostListener, Component, ChangeDetectionStrategy, ViewEncapsulation, ContentChild, TemplateRef, Inject, forwardRef, ElementRef, InjectionToken, ViewContainerRef, Injector, signal, IterableDiffers, ViewChild, computed, DOCUMENT, ContentChildren, NgZone, input, effect, NgModule } from '@angular/core';
+import { EventEmitter, Directive, Input, Output, HostListener, Component, ChangeDetectionStrategy, ViewEncapsulation, ContentChild, TemplateRef, Inject, forwardRef, ElementRef, InjectionToken, ViewContainerRef, Injector, signal, IterableDiffers, ViewChild, computed, ContentChildren, NgZone, input, effect, NgModule } from '@angular/core';
+import { DOCUMENT } from '@angular/common';
import { __decorate } from 'tslib';
import { BehaviorSubject, Subject, fromEvent, merge } from 'rxjs';
Hi! 馃憢
Firstly, thanks for your work on this project! 馃檪
Today I used patch-package to patch
@swimlane/ngx-datatable@23.0.1for the project I'm working on.Description of the Problem
When compiling an Angular application (specifically Angular 17+ using the modern esbuild/Vite application builder), the build fails with a fatal error:
No matching export in "node_modules/@angular/core/fesm2022/core.mjs" for import "DOCUMENT".This happens because
DOCUMENTis currently being imported from@angular/coreinside the package's ESM output, but theDOCUMENTtoken actually resides in@angular/common.While Webpack-based builds in older Angular versions allowed this silently, the modern esbuild compiler strictly validates ESM exports and completely crashes when it cannot resolve the import, preventing the application from serving or building. Moving the
DOCUMENTimport to@angular/commonresolves the build failure entirely.Here is the diff that solved my problem: