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
Critical dependency: the request of a dependency is an expression - /webgpu/webgpu-graphics-device.js #5730
Comments
Thank you for pointing it out! Happens since #5711 We should stick to In addition to this webpack issue, we can also no longer use relative paths because of |
I believe it is due to those 2 lines: engine/src/platform/graphics/webgpu/webgpu-graphics-device.js Lines 169 to 172 in 3fc8bf0
Here the guys suggest to explicitly convert to string: However, it sounds like a webpack issue? Not sure the engine should support it, as it has chosen rollup. |
We have to be agnostic about that, the engine (ESM files in npm package) are consumed by third-party bundlers to create a user bundle |
Any thoughts on this @slimbuck ? |
We have a mentioned of it here: https://forum.playcanvas.com/t/engine-release-v1-66-0/33297/3 |
The previous method of loading glslang with a script tag was actually loading a 'loader script' which performed the dynamic import (see here). The loader script was downloading the actual wasm glue script via CDN (unacceptable) and using a dynamic import statement anyway (though it included the webpackIgnore comment and so worked with webpack). So it seems we have two options to address this issue:
The second option is the simplest and least invasive. Can anyone test that the following works correctly with webpack?: const results = await Promise.all([
import(`${twgslUrl}`).then(module => twgsl(twgslUrl.replace('.js', '.wasm'))),
import(`${glslangUrl}`).then(module => module.default())
]); |
Lovely - thank you so much! I'll merge the fix then. |
The issue still happens if webpack tries to use prebuilt es5 playcanvas engine ( One possible solution is to add ...
module: {
...
noParse: [
// ignore imports and requires in playcanvas build
/playcanvas\./
],
...
}
... |
Wow, what a chain of issues rewriting that dynamically added Can't you use ESM version aswell if you put |
It's likely this script import will be cause this issue as well. |
@kungfooman I use Typescript so using default ESM import works, but my output target is ES5 and I import prebuilt ES5 version of the playcanvas engine to avoid needing to recompile entire playcanvas source code on each update during development and when creating production builds. |
We're in the same boat as @pavle-goloskokovic . While we can use ESM in our projects, it would require us to turn on transpilation of dependencies in In our case, webpack tries to resolve the dynamic imports at build time and spits out hundreds of errors stemming from files within the ESM-module folder of the playcanvas package. The |
@marklundin is just cooking this one, any feedback? |
Title: Critical dependency error in playcanvas module with webpack
Issue description
When building my project, webpack throws a critical dependency warning associated with the playcanvas module.
The warning states
Steps to Reproduce
Environment
Node: ^16.0.0 || ^18.0.0
npm: ^7.0.0 || ^8.0.0 || ^9.0.0
playcanvas version: 1.66.0
webpack version: ^5.76.3
Expected behavior
The project should build without any critical dependency warnings.
Actual behavior
Webpack throws a warning regarding a critical dependency issue in the playcanvas module.
The text was updated successfully, but these errors were encountered: