Skip to content

Can't resolve '/Users/zzzzz/git/www/yyyyy/dist/webpack.1.__datadog-helper-file.js' - webpack output.clean #304

@karpiuMG

Description

@karpiuMG

Describe what happened

Module not found: Error: Can't resolve '/Users/zzzzz/git/www/yyyyy/dist/webpack.1.__datadog-helper-file.js' - the datadogWebpackPlugin creates this file and depends on it

When webpack's build starts — and if output.clean: true is set (which is a standard practice), webpack wipes dist/ before building, deleting the helper file

Steps to reproduce the issue:

  1. set output.clean: true in webpack config
  2. set datadogWebpackPlugin
    plugins: [
    datadogWebpackPlugin({
    rum: {
    enable: true,
    sourceCodeContext: {
    service: config.module.name,
    version: config.packageJsonVersion || '0.0.0',
    },
    },
    })]
  3. run devServer

Expected behaviour:

datadog-helper-file.js isn't deleted when the app runs so the datadogWebpackPlugin works fine

Actual behaviour:

  1. Injection plugin's compiler function runs, creates the file at dist/webpack.1.__datadog-helper-file.js via
    outputFileSync (xpack.ts:35)
  2. Entry points are modified to include this file path (xpack.ts:170-171)
  3. Webpack's build starts — and if output.clean: true is set, webpack wipes dist/ before building, deleting the helper file
  4. Webpack's resolver then tries to find the file and fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions