2023-08-11 14:29:14 +08:00
|
|
|
import { mustNotCall } from '../common/index.mjs';
|
|
|
|
import * as fixtures from '../common/fixtures.mjs';
|
2018-02-15 04:55:49 +08:00
|
|
|
import assert from 'assert';
|
|
|
|
|
2023-08-11 14:29:14 +08:00
|
|
|
Object.defineProperty(Error.prototype, 'url', {
|
|
|
|
get: mustNotCall('get %Error.prototype%.url'),
|
|
|
|
set: mustNotCall('set %Error.prototype%.url'),
|
|
|
|
});
|
|
|
|
Object.defineProperty(Object.prototype, 'url', {
|
|
|
|
get: mustNotCall('get %Object.prototype%.url'),
|
|
|
|
set: mustNotCall('set %Object.prototype%.url'),
|
|
|
|
});
|
2018-08-28 23:28:46 +08:00
|
|
|
|
2023-08-11 14:29:14 +08:00
|
|
|
await assert.rejects(import('../fixtures/es-modules/pjson-main'), {
|
|
|
|
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
|
|
|
|
url: fixtures.fileURL('es-modules/pjson-main').href,
|
|
|
|
});
|
2024-10-23 00:09:32 +08:00
|
|
|
await assert.rejects(import(`data:text/javascript,import${encodeURIComponent(JSON.stringify(fixtures.fileURL('es-modules/pjson-main')))}`), {
|
|
|
|
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
|
|
|
|
url: fixtures.fileURL('es-modules/pjson-main').href,
|
|
|
|
});
|
|
|
|
await assert.rejects(import(`data:text/javascript,import${encodeURIComponent(JSON.stringify(fixtures.fileURL('es-modules/does-not-exist')))}`), {
|
|
|
|
code: 'ERR_MODULE_NOT_FOUND',
|
|
|
|
url: fixtures.fileURL('es-modules/does-not-exist').href,
|
|
|
|
});
|
2018-08-28 23:28:46 +08:00
|
|
|
|
2023-08-11 14:29:14 +08:00
|
|
|
assert.deepStrictEqual(
|
|
|
|
{ ...await import('../fixtures/es-modules/pjson-main/main.mjs') },
|
|
|
|
{ main: 'main' },
|
|
|
|
);
|