2024-10-29 16:08:12 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
2025-10-07 14:40:05 +02:00
|
|
|
const common = require('../common');
|
2024-10-29 16:08:12 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
|
const { registerHooks } = require('module');
|
|
|
|
|
|
|
|
|
|
// Test that module syntax detection works.
|
|
|
|
|
const hook = registerHooks({
|
2025-10-07 14:40:05 +02:00
|
|
|
load: common.mustCall((url, context, nextLoad) => {
|
2024-10-29 16:08:12 +01:00
|
|
|
const result = nextLoad(url, context);
|
|
|
|
|
assert.strictEqual(result.source, '');
|
|
|
|
|
return {
|
|
|
|
|
source: 'export const hello = "world"',
|
|
|
|
|
};
|
2025-10-07 14:40:05 +02:00
|
|
|
}),
|
2024-10-29 16:08:12 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mod = require('../fixtures/empty.js');
|
|
|
|
|
assert.strictEqual(mod.hello, 'world');
|
|
|
|
|
|
|
|
|
|
hook.deregister();
|