[Fixed] ServiceStack with Angular (9) compilation error after upgrade from 1.0.46 to 1.0.47

Issue

In our package.json we used ^ to declare the package reference @servicestack/client. Since the last update of the ServiceStack repo to the new version 1.0.47 we get the following error:

ERROR in ./node_modules/@servicestack/client/dist/index.js
Module not found: Error: Can't resolve 'fs' in 'MyProjectPath...\node_modules\@servicestack\client\dist'
ERROR in ./node_modules/@servicestack/client/dist/index.js
Module not found: Error: Can't resolve 'path' in 'MyProjectPath...\node_modules\@servicestack\client\dist'

If we define the version in our package.json fix to @servicestack/client": "1.0.46 the build runs fine

Solution

Looks like Angular’s AOT compiler still does static reference evaluation for code that it doesn’t run at runtime. v1.0.48 works around this by using a dyanmic require resolution.

This is now available from latest @servicestack/client that’s now on npm

  "dependencies": {
    "@servicestack/client": "^1.0.48",
  },

Leave a Reply

(*) Required, Your email will not be published