Skip to content

Spaces in path to project with @module-federation/next-mf result in Unterminated string in JSON at position and HookWebpackError errors #2684

@VityaSchel

Description

@VityaSchel

Describe the bug

I spent 3 hours figuring out why your example https://github.com/module-federation/module-federation-examples/blob/master/nextjs-v14 worked and my project didn't
I removed files one by one, making smaller and smaller changes, I though problem was in bun, in node modules cache, in next.js versions difference, until eventually I was left with two identical projects (I even changed .tsx to .js) but in one directory it worked and it another it didn't

Turns out, if I add spaces to the path where project is and where I'm running it, it will fail to compile throwing this long error:

HookWebpackError: Unterminated string in JSON at position 78
    at makeWebpackError (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/webpack/lib/HookWebpackError.js:48:9)
    at /Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/webpack/lib/Compilation.js:3181:12
    at eval (eval at create (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
-- inner error --
SyntaxError: Unterminated string in JSON at position 78
    at JSON.parse (<anonymous>)
    at ModuleHandler._handleContainerModule (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1079:22)
    at /Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1138:31
    at Array.forEach (<anonymous>)
    at ModuleHandler.collect (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1127:31)
    at /Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1682:72
    at step (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1402:23)
    at Object.next (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1343:20)
    at asyncGeneratorStep$1 (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1165:28)
    at _next (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1183:17)
caused by plugins in Compilation.hooks.processAssets
SyntaxError: Unterminated string in JSON at position 78
    at JSON.parse (<anonymous>)
    at ModuleHandler._handleContainerModule (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1079:22)
    at /Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1138:31
    at Array.forEach (<anonymous>)
    at ModuleHandler.collect (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1127:31)
    at /Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1682:72
    at step (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1402:23)
    at Object.next (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1343:20)
    at asyncGeneratorStep$1 (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1165:28)
    at _next (/Users/hloth/Downloads/module-federation-examples/files fuck me/node_modules/@module-federation/manifest/dist/index.cjs.js:1183:17)

Reproduction

https://github.com/module-federation/module-federation-examples/blob/master/nextjs-v14

Used Package Manager

npm

System Info

N/A

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions