-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -324,6 +324,26 @@ export default testSuite(({ describe }, node: NodeApis) => { | |||||||||||||
expect(stdout).toBe('Fails as expected 1\nfoo bar\nfoo bar\nFails as expected 2'); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('mts from commonjs', async () => { | ||||||||||||||
await using fixture = await createFixture({ | ||||||||||||||
'import.cjs': ` | ||||||||||||||
const { tsImport } = require(${JSON.stringify(tsxEsmApiCjsPath)}); | ||||||||||||||
(async () => { | ||||||||||||||
const { message } = await tsImport('./file.mts', __filename); | ||||||||||||||
console.log(message); | ||||||||||||||
})(); | ||||||||||||||
`, | ||||||||||||||
'file.mts': 'export const message = "foo bar"', | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
const { stdout } = await execaNode(fixture.getPath('import.cjs'), [], { | ||||||||||||||
nodePath: node.path, | ||||||||||||||
nodeOptions: [], | ||||||||||||||
}); | ||||||||||||||
expect(stdout).toBe('foo bar'); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fasttime
|
if (!data.active) { | |
return nextLoad(url, context); | |
} |
In tsImport
, this isn't used because requests are name-spaced. So if the request doesn't contain the namespace as a part of the request, it will be ignored as well:
Lines 33 to 35 in efb3509
if (data.namespace && data.namespace !== getNamespace(url)) { | |
return nextLoad(url, context); | |
} |
I considered opening a feature request for an unregister
method in Node, but I figured what I have was sufficient. And considering how long it takes to register a hook in Node (practically negligible but notable if you're micro-benching), I figured there would be an equal amount of overhead to removing it.
@fasttime
RE: eslint/rfcs#117 (comment)
Sorry, I prefer not to discuss in that thread since debugging tsx is off-topic (pings everyone & pollutes conversation).
There was a bug here but it's fixed now—you should be able to import a (TypeScript) module file from a CommonJS file.