Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Existing sourcemap files in npm packages #167

Open
Spektr opened this issue Nov 26, 2021 · 7 comments
Open

Existing sourcemap files in npm packages #167

Spektr opened this issue Nov 26, 2021 · 7 comments

Comments

@Spektr
Copy link

Spektr commented Nov 26, 2021

Describe the bug
In npm packages, we have .js.map files that link to nothing, which can lead to warnings in the webpack.

To Reproduce
install npm packages ))

Expected behavior
there are no any .js.map files in prod

Additional context
plz extend the build script by using tsconfig for prod, or maybe there is more elegant solution

@xyy94813
Copy link

xyy94813 commented Dec 17, 2021

WARNING in ./node_modules/@react-keycloak/core/lib/context.js
Module Warning (from ./node_modules/thread-loader/dist/cjs.js):
Failed to parse source map from '{yourProjectPath}/node_modules/@react-keycloak/core/lib/@react-keycloak/core/context.ts' file: Error: ENOENT: no such file or directory, open '{yourProjectPath}/node_modules/@react-keycloak/core/lib/@react-keycloak/core/context.ts'
 @ ./node_modules/@react-keycloak/core/lib/index.js 2:0-26 2:0-26
 @ ./node_modules/@react-keycloak/web/lib/provider.js 1:0-58 3:35-53
 @ ./node_modules/@react-keycloak/web/lib/index.js 1:0-27 1:0-27
 @ ./src/App.tsx 8:0-80 60:30-46
 @ ./src/index.tsx 7:0-24 11:33-36

@xyy94813
Copy link

xyy94813 commented Dec 17, 2021

I use [ignoreWarning](https://webpack.js.org/configuration/other-options/#ignorewarnings) to ignore the warning.

This is a workaround before we resolve the problem.

// in webpack config
module.export = {
  // ...
  ignoreWarnings: [
    {
      module: /@react-keycloak/,
      message: /Failed to parse source map from/,
    }
  ]
}

if you use CRA with CRACO.

// in .cracorc.js

const ignoreWarnings = options => config => {
  if (!config.ignoreWarnings) {
    config.ignoreWarnings = [];
  }

  config.ignoreWarnings.push(...options);
  return config;
};

module.export = {
  webpack: {
    configure: (webpackConfig, { env }) => [
      ignoreWarnings([
        {
          module: /@react-keycloak/,
          message: /Failed to parse source map from/,
        },
      ]),
    ].filter(Boolean).reduce((config, next) => next(config, env) ?? config, webpackConfig),
  },
}

@rue-oplo
Copy link

If we're not using CRACO is there a solution?

I've not been able to install CRACO in the project due to the new React Scripts.

@fookoo
Copy link

fookoo commented Dec 28, 2021

+1 I also struggle with this warning

@xyy94813
Copy link

If we're not using CRACO is there a solution?

I've not been able to install CRACO in the project due to the new React Scripts.

You can use CRACO in react-scripts v5, but some middleware need you rewrite by yourself.

I had upgrade react-scripts v4 to v5 in my project.
It seem like work well.

@mario-subo
Copy link

I was able to install craco with --legacy-peer-deps but I would prefer not to have to resort to that to be honest

@gnowland
Copy link

gnowland commented Dec 6, 2022

I submitted a PR to fix this #200

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

No branches or pull requests

6 participants