Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Typescript UMD import problems into ESNext module

Historically most of my browser projects have been built with UMD modules. I'm trying to switch over to ESNext.

I'm just trying to import a UMD module, like so:

import {Chart, ChartDataSets, ChartConfiguration} from './com/chart';

Typescript is fine with this, but the browser throws the error: Loading module from [...]/com/chart was blocked because of a disallowed MIME type (“text/html”).

Fine. So I tried it with the js file extension:

import {Chart, ChartDataSets, ChartConfiguration} from './com/chart.js';

I get: Import not found: Chart.

Tried to import the whole thing:

import * as Chart from './com/chart.js';

Chart is not a constructor. Chart.Chart is undefined.

Tried it as a reference type, including a script tag in the HTML:

///<reference types='./com/chart'/>

This isn't ideal, but it worked. However, Typescript doesn't like it:

'Chart' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts(2686)

Yeah, I tried adding an import. I'm not clear on something. Why is the module being treated differently when I import it with the .js file extension?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!