Skip to content

Commit

Permalink
Includes and TS 4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBeeblebrox committed Dec 16, 2022
1 parent 8fa8155 commit 9d4448d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
29 changes: 28 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "mtsc"
version = "4.7.3"
version = "4.9.4"
edition = "2018"
authors = ["S. Beeblebrox"] # <[email protected]>
authors = ["Trin Wasinger"] # <[email protected]>
license = "MIT"

[dependencies]
Expand All @@ -11,6 +11,7 @@ clap = "2.33.3"
html5ever = "0.26.0"
panic-message = "0.3.0"
backtrace = "0.3.64"
regex = "1.7.0"

[build-dependencies]
reqwest = "0.11.6"
Expand Down
2 changes: 1 addition & 1 deletion dependency-licenses/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2016 Kevin B. Knapp (clap), 2018-2019 the Deno authors (Rust v8), 2016 Sean McArthur (reqwest), 2021 Tokio Contributors (Tokio), 2014 The html5ever Project Developers (html5ever), 2016 Jorge Aparicio (panic-message), 2014 Alex Crichton (backtrace-rs)
Copyright (c) 2015-2016 Kevin B. Knapp (clap), 2018-2019 The Deno Authors (Rust v8), 2016 Sean McArthur (reqwest), 2021 Tokio Contributors (Tokio), 2014 The html5ever Project Developers (html5ever), 2016 Jorge Aparicio (panic-message), 2014 Alex Crichton (backtrace-rs), 2014 The Rust Project Developers (regex)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod compilers;
use compilers::{compile_typescript, compile_html, CompileOptions, minify_javascript, MinifyOptions};

use regex::{Regex, Captures};
use clap::{Arg, App};

use backtrace::Backtrace;
Expand Down Expand Up @@ -148,6 +149,11 @@ fn main() {
jsx_fragment
};

let regex = Regex::new(r"//#\s*?include\s+?([^\r\n]+)").unwrap();
let input_text = regex.replace_all(&input_text, |captures: &Captures| {
fs::read_to_string(captures[1].to_string()).expect(format!("Error resolving transform `{}`", captures[0].to_string()).as_str())
}).to_string();

let result = if html {
compile_html(input_text.as_str(), options.clone()).expect("Error compiling HTML")
} else {
Expand Down
4 changes: 3 additions & 1 deletion test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ let xx = {
foo() {
console.log(1+1)
}
}
}

const bar = //#include test_include.ts
1 change: 1 addition & 0 deletions test_include.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Bar {}

0 comments on commit 9d4448d

Please sign in to comment.