Skip to content

Build Error: No matching export in "@angular/core" for import "DOCUMENT"#2278

Description

@Welly0007

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';

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions