Skip to content

Commit

Permalink
assert json, importing image component directly
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyfayock committed Feb 22, 2024
1 parent 9325e76 commit e7b21b2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
15 changes: 3 additions & 12 deletions next-cloudinary/src/components/CldImage/CldImage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useCallback, forwardRef, SyntheticEvent } from 'react';
import Image, { ImageProps } from 'next/image';
import { Image } from 'next/dist/client/image-component.js';
import { ImageProps } from 'next/image';
import { getTransformations } from '@cloudinary-util/util';
import { transformationPlugins } from '@cloudinary-util/url-loader';
import type { ImageOptions, ConfigOptions } from '@cloudinary-util/url-loader';
Expand Down Expand Up @@ -138,18 +139,8 @@ const CldImage = forwardRef<HTMLImageElement, CldImageProps>(function CldImage(p

const handleOnError = useCallback(onError, [pollForProcessingImage, defaultImgKey]);

// Copypasta from https://github.com/prismicio/prismic-next/pull/79/files
// Thanks Angelo!
// TODO: Remove once https://github.com/vercel/next.js/issues/52216 is resolved.

let ResolvedImage = Image;

if ("default" in ResolvedImage) {
ResolvedImage = (ResolvedImage as unknown as { default: typeof Image }).default;
}

return (
<ResolvedImage
<Image
key={imgKey}
{...imageProps}
loader={(loaderOptions) => cloudinaryLoader({ loaderOptions, imageProps, cldOptions, cldConfig: props.config })}
Expand Down
4 changes: 2 additions & 2 deletions next-cloudinary/src/constants/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import nextPkg from 'next/package.json';
import pkg from '../../package.json';
import nextPkg from 'next/package.json' assert { type: "json" };
import pkg from '../../package.json' assert { type: "json" };

export const NEXT_CLOUDINARY_ANALYTICS_PRODUCT_ID = 'A';
export const NEXT_CLOUDINARY_ANALYTICS_ID = 'V';
Expand Down
2 changes: 0 additions & 2 deletions next-cloudinary/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const commonConfig: Options = {
dts: true,
format: ['esm', 'cjs'],
sourcemap: true,
clean: true,
};

export default defineConfig([
Expand All @@ -24,7 +23,6 @@ export default defineConfig([
// moduleResolution: Node(10) support
{
...commonConfig,
clean: false,
entry: ['src/helpers.ts'],
format: 'cjs',
outDir: '.'
Expand Down

0 comments on commit e7b21b2

Please sign in to comment.