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

317
Views
How to load a .geojson file in TypeScript with webpack?

I need data from a .geojson file. I tried two things:

const geojson = require('../../assets/mygeojson.geojson');

This failed with the following error:

Module parse failed: Unexpected token (2:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

My second approach was to use the following:

const geojson = await (await fetch('../../assets/mygeojson.geojson')).json();

This failed with the following error:

Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it) File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
  • ./node_modules/@ngtools/webpack/src/ivy/index.js

I don't know where exactly to enable those experiments mentioned in the error message.

In any event, all I need is the GeoJSON file as a plain JSON object for further use in my code. Is there perhaps a third approach so simply load a file in TypeScript?

about 4 years ago · Juan Pablo Isaza
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!