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

213
Visualizações
After upgrading Angular, webpack module source-map-loader is throwing "this.getOptions is not a function"

I am currently building my angular project via webpack with source-map-loader to extract source maps, like so:

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        enforce: "pre",
        use: ["source-map-loader"],
      },
    ],
  },
};

This works fine with my Angular 11 build. Once I upgrade my angular packages to Angular 12, I begin to get the following error:

Module build failed (from ./node_modules/source-map-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
    at Object.loader (./node_modules/source-map-loader/dist/index.js:21:24)

Removing this section from my webpack module allows the build to succeed but I am no longer extracting the source maps, causing my bundle to increase in size.

I have tried upgrading source-map-loader to latest version and did not change the error. I have dug into the node_module and it is complaining about this section of code:

async function loader(input, inputMap) {
  const options = this.getOptions(_options.default);

I have seen may other questions on here in regards to sass-loader and other style loaders for Vue but this is for Angular and is mad about extracting source maps.

There are some breaking changes when going to Angular 12 but upgrading to webpack 5.0.0 did not seem to make a difference

What are some other things I can do to debug this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

By looking at the source code v1.1.3 we do see

import { getOptions } from "loader-utils";

But after v2.0 or even v3.0, this import was deleted.

It came from the library loader-utils

Since v2.0, package.json doesn't import it anymore.

Looks like it has been deprecated, getOptions should be use from Webpack type instead of loader-utils.

Maybe your error come from a conflict with an old dependencie from your node_modules, you should remove the old one from your directory and try again

rm -rf node_modules/@types/loader-utils
rm -rf node_modules/loader-utils
about 4 years ago · Juan Pablo Isaza Relatório
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