s-KaiNet / spfx-fast-serve

Improve your SharePoint Framework development flow by speeding up the "serve" command :rocket:
MIT License
138 stars 11 forks source link

Compatible with SPFx 1.18? #114

Closed heinrich-ulbricht closed 1 year ago

heinrich-ulbricht commented 1 year ago

I upgraded an existing project from SPFx 1.17 to 1.18, upgraded spfx-fast-serve-helpers to 1.18.0, and it (npm run serve) worked.

Then I did something (not sure what, it involved fiddeling with dependencies, unrelated to spfx-fast-serve) and it stopped working. The error now is:

PS C:\Users\user\Documents\contoso-webpart> npm run serve

> contoso-webpart@1.3.0 serve
> set NODE_ENV=DEVELOPMENT gulp bundle --custom-serve --max_old_space_size=4096 && fast-serve

node:internal/modules/cjs/loader:985
  const err = new Error(message);
              ^

Error: Cannot find module 'C:\Users\user\Documents\contoso-webpart\temp\_webpack_config.json'
Require stack:
- C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\helpers.js
- C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js
- C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\devServer.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at getJSONFile (C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\helpers.js:42:12)
    at Object.getExternalComponents (C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\helpers.js:242:35)
    at Object.<anonymous> (C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\baseConfig.js:82:46)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\user\Documents\contoso-webpart\node_modules\spfx-fast-serve-helpers\lib\webpack\baseConfig.js:24:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\user\\Documents\\contoso-webpart\\node_modules\\spfx-fast-serve-helpers\\lib\\webpack\\helpers.js',
    'C:\\Users\\user\\Documents\\contoso-webpart\\node_modules\\spfx-fast-serve-helpers\\lib\\webpack\\configureWebPack.js',
    'C:\\Users\\user\\Documents\\contoso-webpart\\node_modules\\spfx-fast-serve-helpers\\lib\\webpack\\devServer.js'
  ]
}

Now I am unsure if spfx-fast-serve working at all was just an artifact, and it is not yet compatible with SPFx 1.18. Is it? (That would be fantastic. Cannot work without it.)

heinrich-ulbricht commented 1 year ago

Don't know what I did wrong, but I get this error now even after rolling back to 1.17. Do you have an idea what could cause this?

heinrich-ulbricht commented 1 year ago

After some digging in other issues I found that I might have to add this line to my mergeConfig:

fs.writeFileSync("./temp/_webpack_config.json", JSON.stringify(generatedConfiguration, null, 2));

After adding, it works again. Funny thing: this line was never in place. I noticed that _webpack_config.json is generated on gulp bundle. Maybe I never called that after cleaning up? Dunno. Now it works.

s-KaiNet commented 1 year ago

Just to comment on this - you could check out sample config here, it should be enough to run fast-serve.

heinrich-ulbricht commented 1 year ago

I pretty much did that. With 1.18 it stopped working and I had to add the line. This made it work again. Remove the line: breaks. Add the line: works.

So I'm leaving it in and wait for 1.19 🙃