denoland / deno_ast

Source text parsing, lexing, and AST related functionality for Deno
https://crates.io/crates/deno_ast
MIT License
146 stars 45 forks source link

feat: insert jsx tpl after last import statement #171

Closed marvinhagemeister closed 10 months ago

marvinhagemeister commented 10 months ago

This PR ensures that we insert template declarations after the last import.

Before:

import { jsxssr as _jsxssr } from "react/jsx-runtime";
const $$_tpl_1 = [
  "<div></div>"
];
import Foo from "./foo.ts";
import Bar from "./bar.ts";
const a = _jsxssr($$_tpl_1);

After:

import { jsxssr as _jsxssr } from "react/jsx-runtime";
import Foo from "./foo.ts";
import Bar from "./bar.ts";
const $$_tpl_1 = [
  "<div></div>"
];
const a = _jsxssr($$_tpl_1);