mirror of
https://github.com/hanzoai/sharp.git
synced 2026-10-30 19:37:10 +00:00
22 lines
682 B
JavaScript
22 lines
682 B
JavaScript
import { createRequire } from 'node:module';
|
|
import { resolve } from 'node:path';
|
|
import { suite, test } from 'node:test';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
import pkg from '../../package.json' with { type: 'json' };
|
|
|
|
suite('ESM', () => {
|
|
test('await import', async (t) => {
|
|
t.plan(1);
|
|
const sharp = await import(pathToFileURL(resolve(pkg.module)));
|
|
t.assert.deepStrictEqual(typeof sharp.default.versions, 'object');
|
|
});
|
|
|
|
test('createRequire', async (t) => {
|
|
t.plan(1);
|
|
const require = createRequire(import.meta.url);
|
|
const sharp = require(resolve(pkg.module));
|
|
t.assert.deepStrictEqual(typeof sharp.default.versions, 'object');
|
|
});
|
|
});
|