mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
parent
45425c1146
commit
f5eb177f50
40 changed files with 1115 additions and 173 deletions
78
cli/tests/testdata/compiler_api_test.ts
vendored
78
cli/tests/testdata/compiler_api_test.ts
vendored
|
@ -557,3 +557,81 @@ Deno.test({
|
|||
assertEquals(sourceMap.sourcesContent.length, 1);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "Deno.emit() - JSX import source pragma",
|
||||
async fn() {
|
||||
const { files } = await Deno.emit(
|
||||
"file:///a.tsx",
|
||||
{
|
||||
sources: {
|
||||
"file:///a.tsx": `/** @jsxImportSource https://example.com/jsx */
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<div><></></div>
|
||||
);
|
||||
}`,
|
||||
"https://example.com/jsx/jsx-runtime": `export function jsx(
|
||||
_type,
|
||||
_props,
|
||||
_key,
|
||||
_source,
|
||||
_self,
|
||||
) {}
|
||||
export const jsxs = jsx;
|
||||
export const jsxDEV = jsx;
|
||||
export const Fragment = Symbol("Fragment");
|
||||
console.log("imported", import.meta.url);
|
||||
`,
|
||||
},
|
||||
},
|
||||
);
|
||||
assert(files["file:///a.tsx.js"]);
|
||||
assert(
|
||||
files["file:///a.tsx.js"].startsWith(
|
||||
`import { Fragment as _Fragment, jsx as _jsx } from "https://example.com/jsx/jsx-runtime";\n`,
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "Deno.emit() - JSX import source no pragma",
|
||||
async fn() {
|
||||
const { files } = await Deno.emit(
|
||||
"file:///a.tsx",
|
||||
{
|
||||
compilerOptions: {
|
||||
jsx: "react-jsx",
|
||||
jsxImportSource: "https://example.com/jsx",
|
||||
},
|
||||
sources: {
|
||||
"file:///a.tsx": `export function App() {
|
||||
return (
|
||||
<div><></></div>
|
||||
);
|
||||
}`,
|
||||
"https://example.com/jsx/jsx-runtime": `export function jsx(
|
||||
_type,
|
||||
_props,
|
||||
_key,
|
||||
_source,
|
||||
_self,
|
||||
) {}
|
||||
export const jsxs = jsx;
|
||||
export const jsxDEV = jsx;
|
||||
export const Fragment = Symbol("Fragment");
|
||||
console.log("imported", import.meta.url);
|
||||
`,
|
||||
},
|
||||
},
|
||||
);
|
||||
assert(files["file:///a.tsx.js"]);
|
||||
assert(
|
||||
files["file:///a.tsx.js"].startsWith(
|
||||
`import { Fragment as _Fragment, jsx as _jsx } from "https://example.com/jsx/jsx-runtime";\n`,
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue