Skip to content

Commit

Permalink
fix: import types from the right file
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg committed Apr 9, 2021
1 parent 06ab6c7 commit 92fbe14
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
3 changes: 1 addition & 2 deletions packages/rollup/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TransformFactory } from "imagetools-core/dist/types";
import { OutputFormat } from '../../common/output-formats'
import { TransformFactory, OutputFormat } from "imagetools-core";

export interface PluginOptions {
/**
Expand Down
44 changes: 26 additions & 18 deletions packages/vite/src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ describe('vite-imagetools', () => {

test('relative import', async () => {
const bundle = await build({

logLevel: 'warn',
build: { write: false },
plugins: [
Expand All @@ -229,7 +228,6 @@ describe('vite-imagetools', () => {
const imagePath = join(process.cwd(), 'pexels-allec-gomes-5195763.png')

const bundle = await build({

logLevel: 'warn',
build: { write: false },
plugins: [
Expand All @@ -245,25 +243,35 @@ describe('vite-imagetools', () => {
expect(source).toMatchImageSnapshot()
})

test('non existent file', () => {
// const p = rollup({
// plugins: [
// testEntry(`import Image from "./invalid.png?w=300"`),
// imagetools()
// ]
// })
test('non existent file', async () => {
const p = build({
logLevel: 'warn',
build: { write: false },
plugins: [
testEntry(`
import Image from "./invalid.png?w=300"
export default Image
`),
imagetools()
]
})

// expect(p).rejects.toBeDefined()
await expect(p).rejects.toBeDefined()
})

test('no directives', () => {
// const p = rollup({
// plugins: [
// testEntry(`import Image from "./pexels-allec-gomes-5195763.png"`),
// imagetools()
// ]
// })
test('no directives', async () => {
const p = build({
logLevel: 'warn',
build: { write: false },
plugins: [
testEntry(`
import Image from "./pexels-allec-gomes-5195763.png"
export default Image
`),
imagetools()
]
})

// expect(p).rejects.toBeDefined()
await expect(p).resolves.toBeDefined()
})
})
2 changes: 1 addition & 1 deletion packages/vite/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransformFactory, ImageConfig } from "imagetools-core/dist/types";
import { TransformFactory, ImageConfig } from "imagetools-core";

export type OutputFormat = (metadata: ImageConfig[]) => any

Expand Down

0 comments on commit 92fbe14

Please sign in to comment.