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

237
Views
Replacing script-loader with webpack 5 asset modules

I'm attempting to replace the deprecated script-loader with webpack 5's Asset Modules.

Currently I have an HTML file with:

import 'script-loader!systemjs';

loading systemjs.

I've tried systemjs-webpack-interop as code without success; I get

Cannot read property 'meta' of undefined

This is on a legacy library project, and I want to be sure that existing code can still consume it. My goal is to make as few changes as possible.

It's not clear to me from the webpack documentation how to approach replacing this. I'm looking for an example configuration that would behave the same way as my original code.

Update

The documentation on Replacing Inline Loader Syntax suggests one option:

// Portion of webpack config
    rules: [
      {
        resourceQuery: /raw/,
        type: 'asset/source'
      }
    ]

// Source file (such as index.js)
import 'systemjs?raw';

This builds, but the output is different. I'm still investigating to see if the differences matter.

One additional piece it seems I will need:

The script-loader documentation says that it will execute the script once in the global context, and recommends the following for migration to raw-loader (for webpack 4):

import('raw-loader!someScript.js')
  .then(rawModule => eval.call(null, rawModule.default))

It appears I can do the same thing with my raw asset import:

import('systemjs?raw')
  .then(rawModule => eval.call(null, rawModule.default));
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!