optimizely/javascript-sdk

Unused code is bundled when using Angular

ErikNijland opened this issue ยท 5 comments

What I wanted to do

I want to include @optimizely/optimizely-sdk to an existing Angular 12.1.1 project.

What I expected to happen

  • No errors in the terminal when running the app with ng serve
  • No errors in the terminal when building the app with ng build
  • No errors in the browser console.

What actually happened

In all three scenarios the following error appears:

Warning: /my/local/path/node_modules/@optimizely/optimizely-sdk/lib/shared_types.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

Steps to reproduce

Link to repository that can reproduce the issue: https://github.com/ErikNijland/optimizely-angular-cli-bug

  • Install the NPM dependencies with npm ci
  • Run ng build or ng serve

@optimizely/optimizely-sdk version: 4.6.0

Browser and version: Chrome 91

node version: v14.17.1

npm version: 7.19.1

We have the same issue. Is there an update?

How's this coming along?

I think this may be related, but Angular also throws this warning on build:

filename.ts depends on '@optimizely/optimizely-sdk'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

This is current as of version 4.9.2.

For the v5 release we're looking / researching whether we need to ship the CJS and UMDs any more. We'll also be sliming down by removing the /lib/ dir.

Relates to #352 and #638

This issue is fixed in versions >= 4.9.2. Closing this issue