Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset module source map sources are invalid and omit sourcesContent #1222

Closed
colinrotherham opened this issue Jul 29, 2024 · 1 comment · Fixed by webpack/webpack#18639
Closed

Comments

@colinrotherham
Copy link

Bug report

When using the new webpack@5.93.0 binary generator option (see issue #962) the source map JSON is missing sourcesContent and has invalid webpack:///data:; content inside the sources array.

This also affects previous releases using modern or modern-compiler API option too.

Note: Unlike the legacy compiler, missing sourcesContent can be restored with sourceMapContents: true sourceMapIncludeSources: true but the sources property remains invalid.

Actual Behavior

Source map sourcesContent is missing and sources content includes encoded content

- {"version":3,"sourceRoot":"","sources":["webpack:///../node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss",
+ {"version":3,"sourceRoot":"","sources":["webpack:///data:;charset=utf-8,:root%20%7B%0A%20%20//

In Safari web inspector, this is logged with Failed to load resource: unsupported URL

Expected Behavior

Source map sourcesContent is included by default and sources content is correctly encoded

How Do We Reproduce?

See minimal reproduction repo in colinrotherham/sass-loader-source-maps

This follows the README asset module approach via the following rule:

{
  test: /\.scss$/,
  type: 'asset/resource',
  generator: {
    binary: false,
    filename: '[name].css[query]'
  },
  use: [
    {
      loader: 'sass-loader',
      options: {
        // api: 'legacy', // ✅
        // api: 'modern', // ❌
        // api: 'modern-compiler', // ❌
        sassOptions: {
          quietDeps: true,
          style: 'expanded'
        }
      }
    }
  ]
}

Please paste the results of npx webpack-cli info here, and mention other relevant information

  System:
    OS: macOS 14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
    Memory: 565.87 MB / 32.00 GB
  Binaries:
    Node: 20.11.0 - ~/.asdf/installs/nodejs/20.11.0/bin/node
    Yarn: 1.22.22 - ~/.asdf/installs/nodejs/20.11.0/bin/yarn
    npm: 10.2.4 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 126.0.6478.183
    Safari: 17.5
  Packages:
    sass-loader: ^16.0.0 => 16.0.0
    webpack: ^5.93.0 => 5.93.0
    webpack-cli: ^5.1.4 => 5.1.4
colinrotherham added a commit to DEFRA/forms-designer that referenced this issue Jul 29, 2024
colinrotherham added a commit to DEFRA/forms-runner that referenced this issue Jul 29, 2024
@alexander-akait
Copy link
Member

alexander-akait commented Jul 30, 2024

hm, I think the bug in webpack, maybe we don't have data: protocol properly, I will look deeply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants