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

188
Views
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 answers
Answer question

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 Report
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!