New changes in the typescript servicestack-client silently breaks builds done with webpack. It is silent in that webpack still outputs the bundle, but the resulting build leads to no javascript being run:
WARNING in ./node_modules/@servicestack/client/dist/index.js
24:51-58 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
@ ./node_modules/@servicestack/client/dist/index.js
@ ./src/shared/index.tsx
@ ./src/index.tsx
@ multi ./node_modules/react-scripts-ts/config/polyfills.js ./src/index.tsx
My guess is that the conditional require is the culprit:
Downgrading to version ā1.0.48ā seems to fix it (this version does not have the conditional require):
Steps to reproduce:
x new react-spa ProjectName
cd ProjectName/ProjectName
Change the @servicestack/client dependency version to be ^1.0.49 in package.json
npm install
Run the project (the error occurs in dev mode as well as a prod build)
Should be resolved in ^1.0.50 by guarding against accessing nodeās undefined require function.
Note: Itās intended to use require dynamically so that it only requires the fetch polyfill in node.js, using @servicestack/client in the browser is stand-alone & doesnāt need to import any dependencies.
In the latest release weāve also switched from fetch-everywhere to cross-fetch since fetch-everywhere is abandoned and was referencing an outdated version of node-fetch which has vulnerabilities.
iām still getting this with @servicestack/client 1.0.51
i donāt need the nodejs bits where iām at currentlyā¦ the following structure avoids the error in my react webpack context, would it still work for the node contexts youāre covering?
./node_modules/@servicestack/client/dist/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
my project is built up from the main npx create-react-app baselineā¦ going back a year or so ago, i definitely tried starting with the service stack react-spa template but vaguely remember something about the ss templateās dev.js startup flow wasnāt giving me the full npm start experience i was accustomed to from CRA
this warning looks to be triggering from react-scriptsā internal webpack/eslint configā¦
iām hoping to remain un-ejected and have a ārewireā library in play (@craco) so i could probably silence this warning with a config override but would be nice to reach more compatible resolution
it is just a warning in dev mode but i think these turn into errors in production npm run buildā¦ double checking that nowā¦hmmm ā¦ i got a āfailed to compileā error but need to find a log to see if itās related or some other issue due to other recent module upgrades
ok can confirm just a warning, production build does not failā¦ so i can live with itā¦ thereās of course the usual preference to keep that output as clean as possible
I prefer not to use eval in JS which is generally regarded as bad practice, apart from the added security flags it raises, it can also degrade performance.