Closed tommarshall closed 2 years ago
Hi @tommarshall,
Thank you for the details and opening the issue here.
As far as I understand the tslib
is just a runtime library for typescript
and as such should not be part of the public API or be listed as a dependency of the project. I would assume that you would get similar error if you used something other than transformImageUrl
, is that correct?
tslib
is (or is not) needed depending on how your build process is set up. In your case the proper solution would just be to include it in your own devDependencies
(again not dependencies
because it's only needed for building your app) as you have already done ;)
Brief bug description
When importing
transformImageUrl
from@kentico/kontent-delivery
to build image transformation URLs, e.g. within a custom loader forNext/Image
.Repro steps
cms-kontent
example from the Next.js repo.yarn build
to build the project.Expected behaviour
The build should succeed.
Actual behaviour
The build fails with the following error:
Test environment
Additional context
Adding
tslib
as a dependency to the Next project (e.g.yarn add tslib
) fixes the error.tslib
is present in the@kentico/kontent-delivery
package-lock.json
, but it's listed as adev
dependency.Assuming
transformImageUrl
is part of the public API, which it appears to be as it's documented, then I thinktslib
needs to be moved from a dev dependency to a standard dependency.That's a straightforward fix that I can open a PR for, but given the error is occurring within a module of
kontent-core
, I'm not sure whether the right place to do that is in@kentico/kontent-delivery
or downstream in@kentico/kontent-core
. Guidance would be appreciated here...To date I think this has gone unnoticed as the majority of Kontent projects are likely importing other packages that depend on
tslib
, e.g. Kontent Starter Corporate - Next.js, which includestslib
as a dependency ofeslint-config-next
(via@typescript-eslint/parser
->@typescript-eslint/typescript-estree
->tsutils
->tslib
)