Former-commit-id: 0fb2584f15
This commit is contained in:
Jarred Sumner
2021-06-02 20:37:04 -07:00
parent 3bd725d80b
commit 21a1134de3
5 changed files with 39 additions and 13 deletions

3
.gitignore vendored
View File

@@ -33,4 +33,5 @@ coverv
bench
github
out.*
out
out
.parcel-cache

19
.vscode/launch.json vendored
View File

@@ -22,6 +22,21 @@
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "Demo Serve",
"program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
"args": [
"./src/index.tsx",
"--resolve=lazy",
"--outdir=public",
"--serve",
"--public-url=http://localhost:9000/"
],
"cwd": "${workspaceFolder}/demos/simple-react",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
@@ -30,8 +45,8 @@
"args": [
"./src/index.tsx",
"--resolve=dev",
"--outdir=public",
"--public-url=http://localhost:8080/"
"--outdir=out",
"--public-url=http://localhost:9000/"
],
"cwd": "${workspaceFolder}/demos/simple-react",
"console": "internalConsole"

View File

@@ -418,7 +418,7 @@ pub const Cli = struct {
if (!did_write) {
for (result.output_files) |file, i| {
try stdout.unbuffered_writer.writeAll(file.contents);
try stdout.writeAll(file.contents);
if (i > 0) {
_ = try writer.write("\n\n");
}

View File

@@ -44,6 +44,8 @@ pub const FeatureFlags = struct {
pub const jsx_runtime_is_cjs = true;
pub const cache_node_module_output_in_memory = true;
pub const CSSModulePolyfill = enum {
// When you import a .css file and you reference the import in JavaScript
// Just return whatever the property key they referenced was
@@ -63,8 +65,9 @@ pub const Output = struct {
if (isWasm) {
return std.io.FixedBufferStream([]u8);
} else {
var stdin = std.io.getStdIn();
return @TypeOf(std.io.bufferedWriter(stdin.writer()));
return std.fs.File;
// var stdout = std.io.getStdOut();
// return @TypeOf(std.io.bufferedWriter(stdout.writer()));
}
};
stream: StreamType,
@@ -92,6 +95,13 @@ pub const Output = struct {
return source.stream.writer();
}
pub fn flush() void {
if (isNative) {
// source.stream.flush() catch {};
// source.error_stream.flush() catch {};
}
}
pub fn printErrorable(comptime fmt: string, args: anytype) !void {
if (isWasm) {
try source.stream.seekTo(0);

View File

@@ -30,14 +30,14 @@ pub fn main() anyerror!void {
// var root_alloc = std.heap.ArenaAllocator.init(std.heap.raw_c_allocator);
// var root_alloc_ = &root_alloc.allocator;
try alloc.setup(std.heap.c_allocator);
var stdout_file = std.io.getStdIn();
var stdout = std.io.bufferedWriter(stdout_file.writer());
var stderr_file = std.io.getStdErr();
var stderr = std.io.bufferedWriter(stderr_file.writer());
var stdout = std.io.getStdOut();
// var stdout = std.io.bufferedWriter(stdout_file.writer());
var stderr = std.io.getStdErr();
// var stderr = std.io.bufferedWriter(stderr_file.writer());
var output_source = Output.Source.init(stdout, stderr);
defer stdout.flush() catch {};
defer stderr.flush() catch {};
// defer stdout.flush() catch {};
// defer stderr.flush() catch {};
Output.Source.set(&output_source);
try cli.Cli.start(std.heap.c_allocator, &stdout, &stderr, MainPanicHandler);
try cli.Cli.start(std.heap.c_allocator, stdout, stderr, MainPanicHandler);
}