Skip to content

Commit

Permalink
Improve content_scripts error message
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Aug 1, 2024
1 parent 7288d8e commit fc52456
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions programs/develop/webpack/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ export function handleMultipleAssetsError(
) {
const extFilename = filename.split('.').pop()
const errorMsg =
`[${manifestName}'s content_scripts] One of your ${extFilename} ` +
`file imports is also defined as a content_script in manifest.json. Remove the ` +
`duplicate entry and try again.`
`content_scripts: One of your ${extFilename?.toUpperCase()} ` +
`imports is also a content_script CSS in manifest.json.\n\n` +
`Remove the duplicate entry and try again.`

if (filename.startsWith('content_scripts')) {
return errorMsg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import webpack from 'webpack'
import * as messages from '../../lib/messages'

export function handleMultipleAssetsError(
manifest: {name: string},
error: webpack.WebpackError
): webpack.WebpackError | null {
const actualMsg =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class WebpackCommonErrorsPlugin {
// as multiple assets with the same name,
// or missing dependencies.
compilation.errors.forEach((error, index) => {
const multipleAssetsError = handleMultipleAssetsError(error)
const manifest = require(this.manifestPath)
const multipleAssetsError = handleMultipleAssetsError(manifest, error)
const topLevelAwaitError = handleTopLevelAwaitError(
this.manifestPath,
error
Expand Down
3 changes: 1 addition & 2 deletions programs/develop/webpack/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export default function webpackConfig(
infrastructureLogging: {
level: 'none'
},
// cache: false,
performance: {
hints: false,
maxAssetSize: 999000,
Expand All @@ -207,7 +206,7 @@ export default function webpackConfig(
// Enable native CSS support. Note that it's an experimental feature still under development
// and will be enabled by default in webpack v6, however you can track the progress on GitHub
// here: https://github.com/webpack/webpack/issues/14893.
css: devOptions.mode === 'production',
css: true,
// Support the new WebAssembly according to the updated specification,
// it makes a WebAssembly module an async module.
asyncWebAssembly: true
Expand Down

0 comments on commit fc52456

Please sign in to comment.