terser-webpack-plugin icon indicating copy to clipboard operation
terser-webpack-plugin copied to clipboard

Missing External Files

Open OskarEichler opened this issue 3 years ago • 2 comments

Hey guys,

We are trying to exclude some chunky / unnecessary node_modules files from our bundle by adding them to our externals list like so:

    externals: [
      /pdfmake\.js$/,
      /xlsx\.js$/,
      /vfs\_fonts$/
    ],

However, upon adding them to the list, now suddenly we are getting the error:

Failed to minify the code from this file: 

 	pdfmake/vfs_fonts":1 

Of course this fails, as this part of the code is no longer included in the bundle / chunks.

Unfortunately adding the same files to exclude within the TerserPlugin config doesn't seem to solve the issue:

exclude: [
              /pdfmake\.js$/,
              /xlsx\.js$/,
              /vfs\_fonts$/
            ],

This might be because our chunks are already renamed, or because there still remains a dependency? How can we exclude / ignore these files so that we are able to build?

OskarEichler avatar Sep 16 '22 05:09 OskarEichler

As far as I understand the exclude list doesn't work because the files have already been processed into chunks. It is weird though, that the 'minify code from this file' actually returns the path of a file that actually could be excluded.

Would it be possible to either:

  1. Allow an exclusion of those specific files mentioned in the error message?
  2. Set a boolean flag to automatically ignore the chunks that have missing files and not minimize them?

Please let me know!

OskarEichler avatar Sep 16 '22 05:09 OskarEichler

Allow an exclusion of those specific files mentioned in the error message?

Sorry, it is impossible do here

Set a boolean flag to automatically ignore the chunks that have missing files and not minimize them?

We have the exclude option

Failed to minify the code from this file: pdfmake/vfs_fonts":1

It means you module still not considere as external (maybe wrong regexp?)

Please use the issue template and avoid asking question about versions and how we can reproduce it, thank you

alexander-akait avatar Sep 16 '22 12:09 alexander-akait

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

alexander-akait avatar May 03 '23 18:05 alexander-akait