Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda