maxisam / ngx-clipboard

A pure angular clipboard directive
http://maxisam.github.io/ngx-clipboard/
MIT License
504 stars 93 forks source link

Problem with ngx-window-token dependency #282

Closed vegarda closed 2 years ago

vegarda commented 2 years ago

angular@10

ngx-clipboard@14.0.1

ERROR in ./node_modules/ngx-window-token/fesm2015/ngx-window-token.mjs 3:19-33
Can't import the named export 'InjectionToken' from non EcmaScript module (only default export is available)
@ ./node_modules/ngx-clipboard/fesm2015/ngx-clipboard.js
AliKholmatov commented 2 years ago

@maxisam Could you help with it, please? the same issue

KrakenTyio commented 2 years ago

same issue on node 16 and angular 11

happens only on docker build, in regular local release is sometimes ok (depend on local version od env)

Warning: /app/node_modules/ngx-window-token/fesm2015/ngx-window-token.mjs depends on '@angular/core'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Error: ./node_modules/ngx-window-token/fesm2015/ngx-window-token.mjs 2:19-33
Can't import the named export 'InjectionToken' from non EcmaScript module (only default export is available)
    at HarmonyImportSpecifierDependency._getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:88:6)
    at HarmonyImportSpecifierDependency.getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:68:16)
    at Compilation.reportDependencyErrorsAndWarnings (/app/node_modules/webpack/lib/Compilation.js:1463:22)
    at /app/node_modules/webpack/lib/Compilation.js:1258:10
    at _next0 (eval at create (/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:43:1)
    at eval (eval at create (/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:57:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
 @ ./node_modules/ngx-clipboard/__ivy_ngcc__/fesm2015/ngx-clipboard.js
 @ ./src/app/settings/webbooking/wb-weblinks/wb-weblinks.component.ts
 @ ./src/app/settings/settings.module.ts
 @ ./src/lazy/finance.setup.lazy.ts
 @ ./src/app/finance/invoice-section/invoice-section-abstract.directive.ts
 @ ./src/app/finance/invoice-section/invoice-treatment-overview/invoice-treatment-overview.component.ts
 @ ./src/app/finance/treatments/treatments-actions-panel/treatments-actions-panel.component.ts
 @ ./src/app/finance/treatments/treatments-actions-panel/treatments-actions-panel.module.ts
 @ ./src/lazy/treatments.lazy.ts
 @ ./src/lib/invoice/invoice.actions.service.ts
 @ ./src/lib/invoice/invoice.actions.module.ts
 @ ./src/base.module.ts
 @ ./src/app.module.ts
 @ ./src/app.ts
 @ multi ./src/app.ts
yann-mangin commented 2 years ago

I can see that a v15.0.0 has been published 30 minutes ago. I tried that version but the error persists with docker build on Jenkins. The error showing is now the following: ERROR in node_modules/ngx-clipboard/lib/ngx-clipboard.service.d.ts:60:21 - error TS2694: Namespace '"/mnt/jenkins/workspace/PRM-6205-resolve-mt-dependencies/ng-tb-journal/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

KrakenTyio commented 2 years ago

for now quick fix to add ngx-window-token as sibling deps in package.json

"ngx-clipboard": "~14.0.1",
"ngx-window-token": "~5.0.0",
maxisam commented 2 years ago

this issue has been discussed at https://github.com/maxisam/ngx-window-token/issues/46

In short, @KrakenTyio 's workaround is good. I will publish another 14 to lock the version today.

sorry about all the chaos and hope everyone can upgrade to Angular 13 soon, you don't need to wait for ngcc anymore in Angular 13 and you will get build cache feature. Both are really time savers

maxisam commented 2 years ago

hi all, please try 14.0.2 thx

maxisam commented 2 years ago

@vegarda is it good to close this?

surajpoddar16 commented 2 years ago

@maxisam Can we do this to support Angular 9 as well i.e ngx-clipboard v13?

zinla commented 2 years ago

node_modules/ngx-window-token/fesm2015/ngx-window-token.mjs open this file

import {InjectionToken} from '@angular/core';
const WINDOW = new InjectionToken('WindowToken', typeof window !== 'undefined' && window.document
    ? { providedIn: 'root', factory: () => window }
    : { providedIn: 'root', factory: () => undefined });
export { WINDOW };

replace with this code

import InjectionToken from '@angular/core';
const WINDOW = new InjectionToken('WindowToken', typeof window !== 'undefined' && window.document
    ? { providedIn: 'root', factory: () => window }
    : { providedIn: 'root', factory: () => undefined });
export { WINDOW };