Skip to content

Commit

Permalink
fix: 🐛 Fixed dts file output
Browse files Browse the repository at this point in the history
  • Loading branch information
dc7290 committed Dec 12, 2024
1 parent a1b735e commit 052d953
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 42 deletions.
9 changes: 4 additions & 5 deletions __tests__/e2e/app/page.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react'

import Image from '../../../image'
import LegacyImage from '../../../legacy/image'
import Picture from '../../../picture'
import RemoteImage from '../../../remote-image'
import RemotePicture from '../../../remote-picture'
import React from 'react'

import Picture from '../../../dist/components/picture'
import ClientComponent from '../components/ClientComponent'

import WithPropsComponent from '../components/WithPropsComponent'
import imgSrc from '../images/img.png'
import legacyImgSrc from '../images/legacy-img.png'
import WithPropsComponent from '../components/WithPropsComponent'

const id = 400

Expand Down
4 changes: 2 additions & 2 deletions image.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Image from './dist/components/image'
export * from './dist/components/image'
import Image from './dist/components/client/image'
export * from './dist/components/client/image'
export default Image
2 changes: 1 addition & 1 deletion image.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/components/image')
module.exports = require('./dist/components/client/image')
2 changes: 1 addition & 1 deletion legacy/image.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import Image from '../dist/components/legacy-image'
import Image from '../dist/components/client/legacy/image'
export default Image
2 changes: 1 addition & 1 deletion legacy/image.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('../dist/components/legacy-image')
module.exports = require('../dist/components/client/legacy/image')
2 changes: 1 addition & 1 deletion picture.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import Picture from './dist/components/picture'
import Picture from './dist/components/client/picture'
export default Picture
2 changes: 1 addition & 1 deletion picture.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/components/picture')
module.exports = require('./dist/components/client/picture')
4 changes: 2 additions & 2 deletions remote-image.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import RemoteImage from './dist/components/remote-image'
export * from './dist/components/remote-image'
import RemoteImage from './dist/components/server/remote-image'
export * from './dist/components/server/remote-image'
export default RemoteImage
2 changes: 1 addition & 1 deletion remote-image.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/components/remote-image')
module.exports = require('./dist/components/server/remote-image')
4 changes: 2 additions & 2 deletions remote-picture.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import RemotePicture from './dist/components/remote-picture'
export * from './dist/components/remote-picture'
import RemotePicture from './dist/components/server/remote-picture'
export * from './dist/components/server/remote-picture'
export default RemotePicture
2 changes: 1 addition & 1 deletion remote-picture.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/components/remote-picture')
module.exports = require('./dist/components/server/remote-picture')
6 changes: 3 additions & 3 deletions src/components/image.tsx → src/components/client/image.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image, { type ImageProps } from 'next/image'
import React, { forwardRef } from 'react'
import getStringSrc from './utils/getStringSrc'
import imageLoader from './utils/imageLoader'
import getStringSrc from '../utils/getStringSrc'
import imageLoader from '../utils/imageLoader'

const CustomImage = forwardRef<HTMLImageElement, ImageProps>((props, forwardedRef) => {
const srcStr = getStringSrc(props.src)
Expand All @@ -23,5 +23,5 @@ const CustomImage = forwardRef<HTMLImageElement, ImageProps>((props, forwardedRe
})
CustomImage.displayName = 'CustomImage'

export { default as getOptimizedImageProps } from './utils/getOptimizedImageProps'
export { default as getOptimizedImageProps } from '../utils/getOptimizedImageProps'
export default CustomImage
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Image, { type ImageProps } from 'next/image'
import React from 'react'
import imageLoader from './utils/imageLoader'
import imageLoader from '../../utils/imageLoader'

const CustomImage = (props: ImageProps) => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Image, { type ImageProps, getImageProps } from 'next/image'
import React, { forwardRef } from 'react'
import getConfig from '../utils/getConfig'
import getStringSrc from './utils/getStringSrc'
import imageLoader from './utils/imageLoader'
import getConfig from '../../utils/getConfig'
import getStringSrc from '../utils/getStringSrc'
import imageLoader from '../utils/imageLoader'

const config = getConfig()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { appendFileSync } from 'fs-extra'
import type { ImageConfigComplete } from 'next/dist/shared/lib/image-config'
import type { ImageProps } from 'next/image'
import React, { forwardRef } from 'react'
import type { Manifest } from '../cli'
import buildOutputInfo from '../utils/buildOutputInfo'
import getConfig from '../utils/getConfig'
import Image from './image'
import type { Manifest } from '../../cli'
import buildOutputInfo from '../../utils/buildOutputInfo'
import getConfig from '../../utils/getConfig'
import Image from '../client/image'

type RemoteImageProps = Omit<ImageProps, 'src'> & {
src: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { appendFileSync } from 'fs-extra'
import type { ImageConfigComplete } from 'next/dist/shared/lib/image-config'
import type { ImageProps } from 'next/image'
import React, { forwardRef } from 'react'
import type { Manifest } from '../cli'
import buildOutputInfo from '../utils/buildOutputInfo'
import getConfig from '../utils/getConfig'
import Picture from './picture'
import type { Manifest } from '../../cli'
import buildOutputInfo from '../../utils/buildOutputInfo'
import getConfig from '../../utils/getConfig'
import Picture from '../client/picture'

type RemotePictureProps = Omit<ImageProps, 'src'> & {
src: string
Expand Down
18 changes: 9 additions & 9 deletions tsup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ export default defineConfig([
{
...cfg,
entry: {
'remote-image': 'src/components/remote-image.tsx',
'remote-picture': 'src/components/remote-picture.tsx',
'remote-image': 'src/components/server/remote-image.tsx',
'remote-picture': 'src/components/server/remote-picture.tsx',
},
external: ['react', 'next', 'next-export-optimize-images', './image', './picture'],
outDir: 'dist/components',
external: ['next-export-optimize-images', '../client/image', '../client/picture'],
outDir: 'dist/components/server',
},

// Client Components
{
...cfg,
entry: {
image: 'src/components/image.tsx',
'legacy-image': 'src/components/legacy-image.tsx',
picture: 'src/components/picture.tsx',
image: 'src/components/client/image.tsx',
'legacy/image': 'src/components/client/legacy/image.tsx',
picture: 'src/components/client/picture.tsx',
},
external: ['react', 'next', 'next-export-optimize-images'],
outDir: 'dist/components',
external: ['next-export-optimize-images'],
outDir: 'dist/components/client',
esbuildOptions: (options) => {
// Append "use client" to the top of the react entry point
options.banner = {
Expand Down

0 comments on commit 052d953

Please sign in to comment.