modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.22k stars 288 forks source link

Can't resolve '/__web-dev-server__web-socket.js #1908

Open naissa12 opened 2 years ago

naissa12 commented 2 years ago

I'm running into the following error when running rush test. It seems to be complaining about a node module in the common folder.

 {
  moduleIdentifier: 'javascript/esm|/Users/test/dev/hz4/common/temp/node_modules/.pnpm/@web+test-runner-commands@0.5.13/node_modules/@web/test-runner-commands/browser/commands.mjs',
  moduleName: '../../../common/temp/node_modules/.pnpm/@web+test-runner-commands@0.5.13/node_modules/@web/test-runner-commands/browser/commands.mjs',
  loc: '20:34-76',
  message: "Module not found: Error: Can't resolve '/__web-dev-server__web-socket.js' in '/Users/test/dev/hz4/common/temp/node_modules/.pnpm/@web+test-runner-commands@0.5.13/node_modules/@web/test-runner-commands/browser'",
  moduleId: '../../../common/temp/node_modules/.pnpm/@web+test-runner-commands@0.5.13/node_modules/@web/test-runner-commands/browser/commands.mjs',
  moduleTrace: [
   [Object], [Object],
   [Object], [Object],
 ...100 lines omitted...
 }
]
<w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|/Users/test/dev/hz4/common/temp/node_modules/.pnpm/babel-loader@8.2.2_b28f37c4b277fc46484d7898c8ed3863/node_modules/babel-loader/lib/index.js!/Users/test/dev/hz4/common/temp/node_modules/.pnpm/ts-loader@9.1.2_typescript@4.5.4+webpack@5.69.1/node_modules/ts-loader/index.js!/Users/test/dev/hz4/apps/ui-alpha/web/src/components/hz-menu-section/HzAppMenu.ts': No serializer registered for ConstDependency
<w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> Array { 9 items } -> ConstDependency
<w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|/Users/test/dev/hz4/common/temp/node_modules/.pnpm/babel-loader@8.2.2_b28f37c4b277fc46484d7898c8ed3863/node_modules/babel-loader/lib/index.js!/Users/test/dev/hz4/common/temp/node_modules/.pnpm/ts-loader@9.1.2_typescript@4.5.4+webpack@5.69.1/node_modules/ts-loader/index.js!/Users/test/dev/hz4/apps/ui-alpha/web/src/components/hz-user-profile/HzUserCard.ts': No serializer registered for ConstDependency
<w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> Array { 8 items } -> ConstDependency
<w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|javascript/esm|/Users/test/dev/hz4/common/temp/node_modules/.pnpm/source-map-loader@2.0.1_webpack@5.69.1/node_modules/source-map-loader/dist/cjs.js!/Users/test/dev/hz4/shared/renderer/build_wasm/UI/renderer.js': No serializer registered for ConstDependency
<w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> Array { 5 items } -> ConstDependency
<w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|javascript/esm|/Users/test/dev/hz4/common/temp/node_modules/.pnpm/source-map-loader@2.0.1_webpack@5.69.1/node_modules/source-map-loader/dist/cjs.js!/Users/test/dev/hz4/shared/client-bitmap-utils/dist/ResourceLoadUtils.js': No serializer registered for ConstDependency
<w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> Array { 9 items } -> ConstDependency
thepassle commented 2 years ago

You're likely importing something from semantic-dom-diff, which leads to an import of @web/test-runner-commands, which uses a virtual module called __web-dev-server__web-socket.js. The file does not exist, so webpack crashes on it. Im not familiar with webpack, but maybe there's a configuration option to externalize or ignore this file.

1bberto commented 1 year ago

I solve this issue by adding this to my Webpack configurations:

externals: {
  '/__web-dev-server__web-socket.js': 'commonjs __web-dev-server__web-socket.js'
}