Error importing .mjs in Angular (Typescript)

See original GitHub issue

Hi Ceci!

I was looking at what it would take to migrate from 2.x to 3.0. In a simple Angular 9 app, I’m getting compile errors trying to import these new modules. I don’t think Typescript likes these .mjs files. I can get past the errors by directly importing the .js file in the package dist directory.

ps - Did you remove the generated api docs? Links here go to broken pages. https://salte-auth.github.io/

Description

In a simple Angular 9 app, import { Redirect } from '@salte-auth/redirect'; yields the following error

ERROR in ./node_modules/@salte-auth/redirect/dist/redirect.mjs 40:19-24 Can’t import the named export ‘Utils’ from non EcmaScript module (only default export is available)

No compile errors with an import like this: import { Redirect } from '@salte-auth/redirect/dist/redirect.js';

Expected outcome

No compile errors starting angular app

Actual outcome

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pherrmanncommented, May 4, 2022

@cecilia-sanare yes, the latest update is importing the *.min.js now and I’m no longer getting those import errors.

1reaction
cecilia-sanarecommented, May 6, 2020

@pherrmann Sorry it took so long, had a couple of issues I needed to resolve with the automated release process.

Can you try it out now with the latest versions of @salte-auth/salte-auth, @salte-auth/wso2, and @salte-auth/redirect?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import .mjs from .ts "Cannot find module '@angular ...
The thing is when I upgrade to angular 13, which uses .mjs instead of .js , my .ts files cannot import libraries and...
Read more >
Angular 13.x - How to fix import * as i0 from '@angular/core ...
But when I try to execute e2e-test I face following error: ... fesm2015/read-mail.mjs:1 import * as i0 from '@angular/core'; ...
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
This code works in CommonJS modules, but will fail in ES modules because relative import paths need to use extensions. As a result,...
Read more >
Angular >=13 | jest-preset-angular - GitHub Pages
Angular 13 introduces ESM package format for Angular packages. ... Cannot find modules error when importing any deep paths from Angular ESM ...
Read more >
What does it take to support Node.js ESM? – The Guild
To specify specific paths for deep imports, you can specify them: ... Currently, the TypeScript compiler can't output .mjs , Check the issue ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found