So I migrated from version 17 to 19, and now the dynamic imports don't work on ng build
.
This import
import('@fingerprintjs/fingerprintjs/dist/fp.esm.js')
results in:
TypeError: Failed to resolve module specifier '@fingerprintjs/fingerprintjs/dist/fp.esm.js'
In version 17, this file was bundled like as fp.esm-Q72BNRQR.js
and dynamic import was rewritten as
import("./fp.esm-Q72BNRQR.js")
So I migrated from version 17 to 19, and now the dynamic imports don't work on ng build
.
This import
import('@fingerprintjs/fingerprintjs/dist/fp.esm.js')
results in:
TypeError: Failed to resolve module specifier '@fingerprintjs/fingerprintjs/dist/fp.esm.js'
In version 17, this file was bundled like as fp.esm-Q72BNRQR.js
and dynamic import was rewritten as
import("./fp.esm-Q72BNRQR.js")
Make sure you have installed the necessary typing for using this library:
npm i --save-dev @types/fingerprintjs__fingerprintjs
You should omit the .esm.js
and just point to the file without the extension, then it works.
The error could be due to some changes in the angular builder (ESBuild) or version update (tsconfig options updated), I am not sure about this.
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
title = 'test';
ngOnInit() {
const data = import('@fingerprintjs/fingerprintjs/dist/fp');
console.log(data);
}
}