linaria: Error: Cannot find module '@linaria/core/processors/BaseProcessor' when building node version in devmode
Environment
webpack config has:
config.externals = [
nodeExternals({
additionalModuleDirs: ['../../node_modules'],
allowlist: [
/^@anansi\/core\/server/,
/^path-to-regexp/,
/\.css$/,
],
}),
];
Building for server side
- Linaria version: 3.0.0-beta.20
- Bundler (+ version): webpack 5.73.0
- Node.js version: v16.15.0
- OS: ubuntu 20.04
Description
ModuleBuildError: Module build failed (from ../../node_modules/@linaria/webpack5-loader/lib/index.js):
Error: Cannot find module '@linaria/core/processors/BaseProcessor'
Require stack:
- /home/ntucker/src/anansi/node_modules/@linaria/babel-preset/lib/utils/getTagProcessor.js
- /home/ntucker/src/anansi/node_modules/@linaria/babel-preset/lib/utils/replaceTagWithValue.js
- /home/ntucker/src/anansi/node_modules/@linaria/babel-preset/lib/index.js
- /home/ntucker/src/anansi/node_modules/@linaria/webpack5-loader/lib/index.js
- /home/ntucker/src/anansi/node_modules/loader-runner/lib/loadLoader.js
- /home/ntucker/src/anansi/node_modules/loader-runner/lib/LoaderRunner.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/NormalModuleFactory.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/Compiler.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/webpack.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/index.js
- /home/ntucker/src/anansi/packages/core/lib/scripts/startDevserver.js
- /home/ntucker/src/anansi/packages/core/lib/scripts/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/ntucker/src/anansi/node_modules/@linaria/babel-preset/src/utils/getTagProcessor.ts:9:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._compile (/home/ntucker/src/anansi/node_modules/source-map-support/source-map-support.js:568:25)
at Object.Module._extensions..js (/home/ntucker/src/anansi/node_modules/fs-monkey/lib/patchRequire.js:141:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
{
request: '/home/ntucker/src/anansi/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].oneOf[1].use[0]!/home/ntucker/src/anansi/node_modules/@linaria/webpack5-loader/lib/index.js??ruleSet[1].rules[0].oneOf[1].use[1]!/home/ntucker/src/anansi/examples/concurrent/src/index.server.tsx',
userRequest: '/home/ntucker/src/anansi/examples/concurrent/src/index.server.tsx',
rawRequest: './src/index.server.tsx',
}
Note: yarn build (building client production) and yarn build:server (building server production) both work. It’s the webpack-dev-server build for node that doesn’t work.
Reproducible Demo
https://github.com/ntucker/anansi/tree/c85f2c42602fda03594966eb7a2b90d3e45cfd4e
- git clone https://github.com/ntucker/anansi
- git checkout c85f2c42602fda03594966eb7a2b90d3e45cfd4e
- yarn install
- yarn build:pkg
- cd examples/concurrent
- yarn start
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 17
Commits related to this issue
- fix(babel): aliases for processors (fixes #984) — committed to callstack/linaria by Anber 2 years ago
For anyone stumbling on this thread, I was able to solve require() compat by switching to fs-require from fs-monkey. https://github.com/ntucker/anansi/pull/1538
Released as
3.0.0-beta.21