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

ContextReplacementPlugin is used to suppress critical dependency warnings caused by require.toUrl in buildModuleUrl #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ module.exports = [{
new webpack.DefinePlugin({
// Define relative base path in cesium for loading assets
CESIUM_BASE_URL: JSON.stringify('')
}),
new webpack.ContextReplacementPlugin(/cesium\/Source\/Core/, ctx => {
// Suppress warnings "require function is used in a way in which dependencies cannot be statically extracted"
// in cesium/Source/Core/buildModuleUrl.js
const { resource, context, dependencies } = ctx;
if (resource === context) {
dependencies.forEach(dependency => dependency.critical = false);
}
return ctx;
})
],

Expand Down
9 changes: 9 additions & 0 deletions webpack.release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ module.exports = [{
new webpack.DefinePlugin({
// Define relative base path in cesium for loading assets
CESIUM_BASE_URL: JSON.stringify('')
}),
new webpack.ContextReplacementPlugin(/cesium\/Source\/Core/, ctx => {
// Suppress warnings "require function is used in a way in which dependencies cannot be statically extracted"
// in cesium/Source/Core/buildModuleUrl.js
const { resource, context, dependencies } = ctx;
if (resource === context) {
dependencies.forEach(dependency => dependency.critical = false);
}
return ctx;
})
]
}];