问题
I'm trying this import in an Angular 9 library:
import * as v1 from "uuid/v1";
And VS Code does not draw any errors with this, however when I try to build the library I get this error:
Error: Cannot call a namespace ('v1')
Also this used to work:
import v1 from "uuid/v1";
However when doing that I get the error:
This module is declared with using ‘export =’, and can only be used with a default import when using the ‘allowSyntheticDefaultImports’ flag.
Thoughts?
Update
I tried this within the workspace tsconfig.json
file:
"compilerOptions": {
"allowSyntheticDefaultImports": true,
...
And went back to:
import v1 from "uuid/v1";
And that works. Just curious whether this is the recommended approach ... WRT Treeshaking etc.
Update 2
Turns out that will not work because now I get these errors:
● should constructor initialize the store
TypeError: v1_1.default is not a function
72 | */
73 | export function GUID() {
> 74 | return v1();
| ^
75 | }
If I go back to
import * as v1 from "uuid/v1";
And VS Code does not draw any errors with this, however when I try to build the library I get this error:
Error: Cannot call a namespace ('v1')
Then the tests run fine, but I get the same error:
Error: Cannot call a namespace ('v1')
Angular Bug Report
https://github.com/angular/angular-cli/issues/16378
来源:https://stackoverflow.com/questions/59221867/angular-build-results-in-error-cannot-call-a-namespace-v1