On [email protected] (currently the latest), I started seeing:
TypeError: Cannot read property 'buildMeta' of undefined
at HarmonyImportSpecifierDependency._getEffectiveExportPresenceLevel (/src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:165:43)
at HarmonyImportSpecifierDependency.getWarnings (/src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:176:32)
at Compilation.reportDependencyErrorsAndWarnings (/src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:3132:24)
at /src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:2729:28
The top frame is (source code here):
/**
* @param {ModuleGraph} moduleGraph module graph
* @returns {number} effective mode
*/
_getEffectiveExportPresenceLevel(moduleGraph) {
if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
return this.exportPresenceMode;
return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
? ExportPresenceModes.ERROR
: ExportPresenceModes.WARN;
}
Why would moduleGraph.getParentModule(this)
be undefined? What should normally prevent it?
I dumped out this
from inside _getEffectiveExportPresenceLevel
and got:
HarmonyImportSpecifierDependency {
_parentModule: undefined,
_parentDependenciesBlock: undefined,
_parentDependenciesBlockIndex: -1,
weak: false,
optional: false,
_locSL: 1,
_locSC: 12241,
_locEL: 1,
_locEC: 12242,
_locI: undefined,
_locN: undefined,
_loc: SourceLocation {
start: Position { line: 1, column: 12241 },
end: Position { line: 1, column: 12242 }
},
request: '@emotion/stylis',
userRequest: '@emotion/stylis',
range: [ 12241, 12242 ],
assertions: undefined,
sourceOrder: 4,
ids: [ 'default' ],
name: 'p',
exportPresenceMode: 2,
namespaceObjectAsContext: false,
call: undefined,
directImport: true,
shorthand: false,
asiSafe: true,
usedByExports: undefined
}
I'm not too sure what this means. Maybe request
or userRequest
are a hint (@emotion/stylis
). I'm not sure if the problem is more on the importing side than the imported and which one this is referring to.
Not sure why this suddenly started happening, suppose some change in package versions. Code and config unchanged lately in that area of the project.
On [email protected] (currently the latest), I started seeing:
TypeError: Cannot read property 'buildMeta' of undefined
at HarmonyImportSpecifierDependency._getEffectiveExportPresenceLevel (/src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:165:43)
at HarmonyImportSpecifierDependency.getWarnings (/src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:176:32)
at Compilation.reportDependencyErrorsAndWarnings (/src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:3132:24)
at /src/project/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:2729:28
The top frame is (source code here):
/**
* @param {ModuleGraph} moduleGraph module graph
* @returns {number} effective mode
*/
_getEffectiveExportPresenceLevel(moduleGraph) {
if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
return this.exportPresenceMode;
return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
? ExportPresenceModes.ERROR
: ExportPresenceModes.WARN;
}
Why would moduleGraph.getParentModule(this)
be undefined? What should normally prevent it?
I dumped out this
from inside _getEffectiveExportPresenceLevel
and got:
HarmonyImportSpecifierDependency {
_parentModule: undefined,
_parentDependenciesBlock: undefined,
_parentDependenciesBlockIndex: -1,
weak: false,
optional: false,
_locSL: 1,
_locSC: 12241,
_locEL: 1,
_locEC: 12242,
_locI: undefined,
_locN: undefined,
_loc: SourceLocation {
start: Position { line: 1, column: 12241 },
end: Position { line: 1, column: 12242 }
},
request: '@emotion/stylis',
userRequest: '@emotion/stylis',
range: [ 12241, 12242 ],
assertions: undefined,
sourceOrder: 4,
ids: [ 'default' ],
name: 'p',
exportPresenceMode: 2,
namespaceObjectAsContext: false,
call: undefined,
directImport: true,
shorthand: false,
asiSafe: true,
usedByExports: undefined
}
I'm not too sure what this means. Maybe request
or userRequest
are a hint (@emotion/stylis
). I'm not sure if the problem is more on the importing side than the imported and which one this is referring to.
Not sure why this suddenly started happening, suppose some change in package versions. Code and config unchanged lately in that area of the project.
Share Improve this question edited Apr 25, 2024 at 4:10 Karl Knechtel 61.5k14 gold badges126 silver badges184 bronze badges asked Apr 18, 2022 at 20:33 NobodyImportant59NobodyImportant59 1862 silver badges10 bronze badges3 Answers
Reset to default 15For me, I have changed some properties of package.json file from
"webpack": "5.71.0",
"webpack-cli": "4.9.2",
"webpack-dev-server": "4.8.0"
to
"webpack": "5.65.0",
"webpack-cli": "4.9.1",
"webpack-dev-server": "4.7.1",
Another version working:
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1",
The project yielding this issue was a pnpm-based monorepo with internal package dependencies using webpack build caches. I found unifying the webpack version throughout the monorepo resolved the issue.
For me,
In Jhipster Java project, I just deleted the target directory (target\webpack\default-development\*
) by
mvn clean install
and it's working