Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Jsx import source #301

Merged
merged 10 commits into from May 16, 2024
Merged

feat: Jsx import source #301

merged 10 commits into from May 16, 2024

Conversation

andreespirela
Copy link
Collaborator

No description provided.

@andreespirela andreespirela changed the title WIP: feat: Jsx import source feat: Jsx import source Mar 27, 2024
@nyannyacha nyannyacha linked an issue Mar 27, 2024 that may be closed by this pull request
nyannyacha
nyannyacha previously approved these changes Mar 27, 2024
Copy link
Collaborator

@nyannyacha nyannyacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I’ve tested in local machine and it worked as normally 😁

@mcandeia
Copy link

mcandeia commented Apr 2, 2024

Heys guys are we ready to merge it? @nyannyacha @andreespirela

@mcandeia
Copy link

mcandeia commented Apr 3, 2024

I don't know If I did something wrong, but I couldn't make it work using this branch. Do you have a working example?

laktek
laktek previously approved these changes Apr 12, 2024
@mcandeia
Copy link

Tested with a fresh project but it did not work. Then I tried to rewrite the entire source code adding jsx pragma and it worked. So I think there are some missing configuration yet

@mcandeia
Copy link

mcandeia commented Apr 14, 2024

image Easy to reproduce, just try it out: https://fresh.deno.dev/docs/getting-started/create-a-project

@nyannyacha
Copy link
Collaborator

@mcandeia

Note:

DEBUG Specifier "https://deno.land/std@0.216.0/dotenv/parse.ts" was not mapped in import map.
DEBUG Specifier "https://deno.land/std@0.216.0/dotenv/stringify.ts" was not mapped in import map.
DEBUG Sending warning alert CloseNotify
DEBUG Sending warning alert CloseNotify
DEBUG Sending warning alert CloseNotify
DEBUG Sending warning alert CloseNotify
runtime has escaped from the event loop unexpectedly: event loop error: TypeError: Invalid Version: supabase-edge-runtime-0.1.0 (compatible with Deno v1.40.3)
    at parse (https://deno.land/std@0.216.0/semver/parse.ts:18:22)
    at ensureMinDenoVersion (https://deno.land/x/fresh@1.6.8/src/dev/mod.ts:9:23)
    at dev (https://deno.land/x/fresh@1.6.8/src/dev/dev_command.ts:9:3)
    at file:///workspaces/edge-runtime/examples/fresh/index.ts:5:7
    at eventLoopTick (ext:core/01_core.js:64:7)
failed to send request to user worker: request has been cancelled by supervisor
user worker failed to respond: request has been cancelled by supervisor
WorkerRequestCancelled: request has been cancelled by supervisor
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:70:21)
    at async callWorker (file:///workspaces/edge-runtime/examples/main/index.ts:114:14)
    at async #respond (https://deno.land/std@0.131.0/http/server.ts:219:18) {
  name: "WorkerRequestCancelled"
}
cancelled!
DEBUG CPU time used: 50ms

support-jsx-import-source-mcandeia

@andreespirela
Copy link
Collaborator Author

This is interesting

TypeError: Invalid Version: supabase-edge-runtime-0.1.0 (compatible with Deno v1.40.3)

@nyannyacha
Copy link
Collaborator

nyannyacha commented Apr 15, 2024

After modifying Deno.version, I was unable to proceed with the error that Deno.stat was not found. 😅

dev.ts -> index.ts

...
DEBUG Specifier "https://deno.land/std@0.216.0/fs/walk.ts" was not mapped in import map.
DEBUG Specifier "https://deno.land/std@0.216.0/dotenv/mod.ts" was not mapped in import map.
DEBUG Specifier "https://deno.land/std@0.216.0/dotenv/parse.ts" was not mapped in import map.
DEBUG Specifier "https://deno.land/std@0.216.0/dotenv/stringify.ts" was not mapped in import map.
runtime has escaped from the event loop unexpectedly: event loop error: TypeError: Deno.stat is not a function
    at collectDir (https://deno.land/x/fresh@1.6.8/src/dev/mod.ts:22:29)
    at collect (https://deno.land/x/fresh@1.6.8/src/dev/mod.ts:51:5)
    at dev (https://deno.land/x/fresh@1.6.8/src/dev/dev_command.ts:23:29)
    at file:///workspaces/edge-runtime/examples/fresh/index.ts:5:7
    at eventLoopTick (ext:core/01_core.js:64:7)
failed to send request to user worker: request has been cancelled by supervisor
user worker failed to respond: request has been cancelled by supervisor
WorkerRequestCancelled: request has been cancelled by supervisor
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:70:21)
    at async callWorker (file:///workspaces/edge-runtime/examples/main/index.ts:114:14)
    at async #respond (https://deno.land/std@0.131.0/http/server.ts:219:18) {
  name: "WorkerRequestCancelled"
}
cancelled!
DEBUG CPU time used: 68ms

main.ts -> index.ts

DEBUG Specifier "file:///workspaces/edge-runtime/examples/fresh/components/Button.tsx" was not mapped in import map.
DEBUG Specifier "https://deno.land/std@0.216.0/path/mod.ts" was not mapped in import map.
DEBUG Specifier "https://deno.land/std@0.216.0/fs/walk.ts" was not mapped in import map.
runtime has escaped from the event loop unexpectedly: event loop error: Error: Could not find a deno.json file in the current directory or any parent directory.
    at readDenoConfig (https://deno.land/x/fresh@1.6.8/src/server/config.ts:32:13)
    at eventLoopTick (ext:core/01_core.js:64:7)
    at async getInternalFreshState (https://deno.land/x/fresh@1.6.8/src/server/config.ts:42:52)
    at async ServerContext.fromManifest (https://deno.land/x/fresh@1.6.8/src/server/context.ts:88:32)
    at async start (https://deno.land/x/fresh@1.6.8/src/server/mod.ts:12:15)
    at async file:///workspaces/edge-runtime/examples/fresh/index.ts:10:1
failed to send request to user worker: request has been cancelled by supervisor
user worker failed to respond: request has been cancelled by supervisor
WorkerRequestCancelled: request has been cancelled by supervisor
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:70:21)
    at async callWorker (file:///workspaces/edge-runtime/examples/main/index.ts:114:14)
    at async #respond (https://deno.land/std@0.131.0/http/server.ts:219:18) {
  name: "WorkerRequestCancelled"

@nyannyacha
Copy link
Collaborator

nyannyacha commented Apr 15, 2024

Command

EDGE_RUNTIME_PORT=9998 ./target/debug/edge-runtime start -v --static "./examples/**/*.json"
// examples/fresh/fresh.gen.ts
...
const manifest = {
  routes: {
    "./routes/_404.tsx": $_404,
    "./routes/_app.tsx": $_app,
    "./routes/api/joke.ts": $api_joke,
    "./routes/greet/[name].tsx": $greet_name_,
    "./routes/index.tsx": $index,
  },
  islands: {
    "./islands/Counter.tsx": $Counter,
  },
  // baseUrl: import.meta.url
  baseUrl: "file://./mnt/data/examples/fresh/fresh.gen.ts", // <- You will not able to make it a relative path whatever you do
} satisfies Manifest;

export default manifest;
import {
    dirname,
    fromFileUrl,
} from "https://deno.land/std@0.222.1/path/mod.ts";

console.log(import.meta.url);
console.log(dirname(fromFileUrl("file://./mnt/data/examples/fresh/fresh.gen.ts")));
[Info] file:///workspaces/edge-runtime/examples/serve/index.ts
[Info] /mnt/data/examples/fresh // 🙄
// Note that this is an ABSOLUTE path.
console.log(Deno.readTextFileSync("/mnt/data/examples/fresh/deno.json"));
DEBUG Snapshot already up to date. Skipping pending resolution.
DEBUG Opening cache /home/vscode/.cache/deno/node_analysis_cache_v1...
runtime has escaped from the event loop unexpectedly: event loop error: NotFound: path not found /mnt/data/examples/serve/deno.json: readfile '/mnt/data/examples/serve/deno.json'
    at Object.readTextFileSync (ext:deno_fs/30_fs.js:832:10)
    at file:///workspaces/edge-runtime/examples/serve/index.ts:3:18
failed to send request to user worker: request has been cancelled by supervisor
user worker failed to respond: request has been cancelled by supervisor
Error in worker connection: connection closed before message completed
DEBUG CPU time used: 0ms
WorkerRequestCancelled: request has been cancelled by supervisor
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:70:21)
    at async callWorker (file:///workspaces/edge-runtime/examples/main/index.ts:114:14)
    at async #respond (https://deno.land/std@0.131.0/http/server.ts:219:18) {
  name: "WorkerRequestCancelled"
}
cancelled!
// Note that this is a RELATIVE path.
console.log(Deno.readTextFileSync("./mnt/data/examples/fresh/deno.json"));
...
DEBUG Snapshot already up to date. Skipping pending resolution.
DEBUG Opening cache /home/vscode/.cache/deno/node_analysis_cache_v1...
[Info] {
  "lock": false,
  "tasks": {
    "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
...

😅

@mcandeia
Copy link

Command

EDGE_RUNTIME_PORT=9998 ./target/debug/edge-runtime start -v --static "./examples/**/*.json"
// examples/fresh/fresh.gen.ts
...
const manifest = {
  routes: {
    "./routes/_404.tsx": $_404,
    "./routes/_app.tsx": $_app,
    "./routes/api/joke.ts": $api_joke,
    "./routes/greet/[name].tsx": $greet_name_,
    "./routes/index.tsx": $index,
  },
  islands: {
    "./islands/Counter.tsx": $Counter,
  },
  // baseUrl: import.meta.url
  baseUrl: "file://./mnt/data/examples/fresh/fresh.gen.ts", // <- You will not able to make it a relative path whatever you do
} satisfies Manifest;

export default manifest;
import {
    dirname,
    fromFileUrl,
} from "https://deno.land/std@0.222.1/path/mod.ts";

console.log(import.meta.url);
console.log(dirname(fromFileUrl("file://./mnt/data/examples/fresh/fresh.gen.ts")));
[Info] file:///workspaces/edge-runtime/examples/serve/index.ts
[Info] /mnt/data/examples/fresh // 🙄
// Note that this is an ABSOLUTE path.
console.log(Deno.readTextFileSync("/mnt/data/examples/fresh/deno.json"));
DEBUG Snapshot already up to date. Skipping pending resolution.
DEBUG Opening cache /home/vscode/.cache/deno/node_analysis_cache_v1...
runtime has escaped from the event loop unexpectedly: event loop error: NotFound: path not found /mnt/data/examples/serve/deno.json: readfile '/mnt/data/examples/serve/deno.json'
    at Object.readTextFileSync (ext:deno_fs/30_fs.js:832:10)
    at file:///workspaces/edge-runtime/examples/serve/index.ts:3:18
failed to send request to user worker: request has been cancelled by supervisor
user worker failed to respond: request has been cancelled by supervisor
Error in worker connection: connection closed before message completed
DEBUG CPU time used: 0ms
WorkerRequestCancelled: request has been cancelled by supervisor
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:70:21)
    at async callWorker (file:///workspaces/edge-runtime/examples/main/index.ts:114:14)
    at async #respond (https://deno.land/std@0.131.0/http/server.ts:219:18) {
  name: "WorkerRequestCancelled"
}
cancelled!
// Note that this is a RELATIVE path.
console.log(Deno.readTextFileSync("./mnt/data/examples/fresh/deno.json"));
...
DEBUG Snapshot already up to date. Skipping pending resolution.
DEBUG Opening cache /home/vscode/.cache/deno/node_analysis_cache_v1...
[Info] {
  "lock": false,
  "tasks": {
    "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
...

😅

Sorry, I forgot to mention that I did a few modifications to make it work as is. First, for sake of simplicity, I've removed the static VFS and switched to DenoCompileFileSystem, second, I set the import map inline so those imports will be resolved automatically,

@nyannyacha @andreespirela want me to setup a reproducible repo?

@mcandeia
Copy link

By the way, we won the product of the week/day at producthunt.com https://www.producthunt.com/posts/deco-cx-2-0

And I saw that you guys posted earlier today ours, amazing!! So our chance to get the product of the month walked away, but nice to have you guys as the one that will win this month. Good luck, you have my vote!

And it will be yet nicer to have you guys a deep integration with us. so running fresh sites is only the first step!

@nyannyacha
Copy link
Collaborator

Hello @mcandeia 😁

Sorry, I forgot to mention that I did a few modifications to make it work as is. First, for sake of simplicity, I've removed the static VFS and switched to DenoCompileFileSystem, second, I set the import map inline so those imports will be resolved automatically,

Actually, I posted the above not only for you, but also for andres.
Because I wanted to show that static fs mounting from ./mnt/data might not work in certain scenarios (like as fresh package 😋).

And I saw that you guys posted earlier today ours, amazing!! So our chance to get the product of the month walked away, but nice to have you guys as the one that will win this month. Good luck, you have my vote!

Thank you!

@nyannyacha
Copy link
Collaborator

want me to setup a reproducible repo?

Yes, That will help 😁
If you create a reproducible repository with changes to this PR, I'd be happy to review it.

@mcandeia
Copy link

want me to setup a reproducible repo?

Yes, That will help 😁 If you create a reproducible repository with changes to this PR, I'd be happy to review it.

I can certainly do that but it's not working e2e, somehow its failing when trying to compile .tsx using the specified JsxImportSource, I have no idea why, needs some deeper investigation. But let me prepare a reproducible repo tomorrow and I'll send it back here

@mcandeia
Copy link

Guys @nyannyacha and @andreespirela, check out this PR:

deco-cx#6 try out yourself, I did the modifications mentioned before and added a examples/fresh-project which you can use to test

@mcandeia
Copy link

mcandeia commented Apr 17, 2024

This is interesting

TypeError: Invalid Version: supabase-edge-runtime-0.1.0 (compatible with Deno v1.40.3)

btw, I think this is not a semver compliant version, that should be the why

@nyannyacha
Copy link
Collaborator

nyannyacha commented Apr 17, 2024

@mcandeia

btw, I think this is not a semver compliant version, that should be the why

Yeah, I didn't realise that property was being parsed as semver by other packages. 😓
I'll have to revisit this.

@nyannyacha
Copy link
Collaborator

(FYI, I am at GMT+9 and start my activity around this time every day. I will now go through your reproducible repository 😋)

@nyannyacha
Copy link
Collaborator

nyannyacha commented Apr 18, 2024

@mcandeia

I looked into the issue in your fork and I think I found what happened.

PR-6/examples/fresh-project/index.tsx (I suffixed an x after it to confirm my theory.)

--- a/examples/fresh-project/index.tsx
+++ b/examples/fresh-project/index.tsx
import "$std/dotenv/load.ts";
 
+debugger;
+
 import { start } from "$fresh/server.ts";
 import manifest from "./fresh.gen.ts";
 import config from "./fresh.config.ts";
 
+function meowTest() {
+    return (
+        <div>meow~</div>
+    );
+}
+
 await start(manifest, config);
스크린샷 2024-04-18 오전 9 11 01

PR-6/examples/fresh-project/routes/index.tsx
스크린샷 2024-04-18 오전 9 01 53

I don't know what happened, but the emit option specified in the entrypoint (which should have been specified as _jsx, not React) was not being passed to the subfile.

cc @andreespirela

@nyannyacha
Copy link
Collaborator

nyannyacha commented Apr 18, 2024

Update:

I've found the problematic line.

eszip::EszipV2::from_graph(graph, &parser, Default::default())
}

--- a/crates/sb_graph/graph_util.rs
+++ b/crates/sb_graph/graph_util.rs
@@ -330,7 +330,7 @@ pub async fn create_eszip_from_graph_raw(
     let parser_arc = emitter.clone().parsed_source_cache().unwrap();
     let parser = parser_arc.as_capturing_parser();
 
-    eszip::EszipV2::from_graph(graph, &parser, Default::default())
+    eszip::EszipV2::from_graph(graph, &parser, emitter.emit_options())
 }
 
 pub async fn create_graph(

I've confirmed that this patch is rendering static HTML content correctly on @mcandeia's PR-6 without file system sandboxing and static fs applied.

Output:

<!DOCTYPE html>
<html>

<head>
    <title>fresh-project</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="/styles.css" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/deserializer.js" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/signals.js" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/main.js" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/island-counter.js" />
</head>

<body>
    <div class="px-4 py-8 mx-auto bg-[#86efac]">
        <div class="max-w-screen-md mx-auto flex flex-col items-center justify-center"><img class="my-6" src="/logo.svg?__frsh_c=d9d51bae574d9c3d4563416258222b74e69df4ee" width="128" height="128" alt="the Fresh logo: a sliced lemon dripping with juice"/>
            <h1 class="text-4xl font-bold">Welcome to Fresh</h1>
            <p class="my-4">Try updating this message in the<code class="mx-2">./routes/index.tsx</code> file, and
                refresh.</p>
            <!--frsh-counter_default:0:-->
            <div class="flex gap-8 py-6">
                <button disabled class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors">-1</button>
                <p class="text-3xl tabular-nums">3</p>
                <button disabled class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors">+1</button>
            </div>
            <!--/frsh-counter_default:0:-->
        </div>
    </div>
    <script id="__FRSH_STATE_4bac2f0c-8d08-4e0a-885a-c51491ebafcc" type="application/json"
        nonce="341dac263ecd40cd91b676254f2f435c">
        {"v":[[{"count":{"_f":"s","v":3}}],[]]}
    </script>
    <script type="module" nonce="341dac263ecd40cd91b676254f2f435c">
        import { deserialize } from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/deserializer.js";import { signal } from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/signals.js";const ST = document.getElementById("__FRSH_STATE_4bac2f0c-8d08-4e0a-885a-c51491ebafcc").textContent;const STATE = deserialize(ST, signal);import { revive } from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/main.js";import counter_default from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/island-counter.js";const propsArr = typeof STATE !== "undefined" ? STATE[0] : [];revive({counter_default:counter_default,}, propsArr);
    </script>
</body>

</html>

Note: This issue also affects a decorator PR I recently submitted.

@mcandeia
Copy link

Update:

I've found the problematic line.

eszip::EszipV2::from_graph(graph, &parser, Default::default())
}

--- a/crates/sb_graph/graph_util.rs
+++ b/crates/sb_graph/graph_util.rs
@@ -330,7 +330,7 @@ pub async fn create_eszip_from_graph_raw(
     let parser_arc = emitter.clone().parsed_source_cache().unwrap();
     let parser = parser_arc.as_capturing_parser();
 
-    eszip::EszipV2::from_graph(graph, &parser, Default::default())
+    eszip::EszipV2::from_graph(graph, &parser, emitter.emit_options())
 }
 
 pub async fn create_graph(

I've confirmed that this patch is rendering static HTML content correctly on @mcandeia's PR-6 without file system sandboxing and static fs applied.

Output:

<!DOCTYPE html>
<html>

<head>
    <title>fresh-project</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="/styles.css" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/deserializer.js" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/signals.js" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/main.js" />
    <link rel="modulepreload" href="/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/island-counter.js" />
</head>

<body>
    <div class="px-4 py-8 mx-auto bg-[#86efac]">
        <div class="max-w-screen-md mx-auto flex flex-col items-center justify-center"><img class="my-6" src="/logo.svg?__frsh_c=d9d51bae574d9c3d4563416258222b74e69df4ee" width="128" height="128" alt="the Fresh logo: a sliced lemon dripping with juice"/>
            <h1 class="text-4xl font-bold">Welcome to Fresh</h1>
            <p class="my-4">Try updating this message in the<code class="mx-2">./routes/index.tsx</code> file, and
                refresh.</p>
            <!--frsh-counter_default:0:-->
            <div class="flex gap-8 py-6">
                <button disabled class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors">-1</button>
                <p class="text-3xl tabular-nums">3</p>
                <button disabled class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors">+1</button>
            </div>
            <!--/frsh-counter_default:0:-->
        </div>
    </div>
    <script id="__FRSH_STATE_4bac2f0c-8d08-4e0a-885a-c51491ebafcc" type="application/json"
        nonce="341dac263ecd40cd91b676254f2f435c">
        {"v":[[{"count":{"_f":"s","v":3}}],[]]}
    </script>
    <script type="module" nonce="341dac263ecd40cd91b676254f2f435c">
        import { deserialize } from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/deserializer.js";import { signal } from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/signals.js";const ST = document.getElementById("__FRSH_STATE_4bac2f0c-8d08-4e0a-885a-c51491ebafcc").textContent;const STATE = deserialize(ST, signal);import { revive } from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/main.js";import counter_default from "/_frsh/js/d9d51bae574d9c3d4563416258222b74e69df4ee/island-counter.js";const propsArr = typeof STATE !== "undefined" ? STATE[0] : [];revive({counter_default:counter_default,}, propsArr);
    </script>
</body>

</html>

Note: This issue also affects a decorator PR I recently submitted.

Amazing! Will test soon.

Just to clarify one thing, do I need to set the file system to be the Deno's Compile one? or there are a command that make it work out of the box?

@nyannyacha
Copy link
Collaborator

@mcandeia

Just to clarify one thing, do I need to set the file system to be the Deno's Compile one? or there are a command that make it work out of the box?

Oh wow, sorry, I'm not a native, so I guess that sentence was ambiguous. 😂
I've confirmed that applying the patch I posted above will render HTML content on your fork.

(However, I've only checked with Postman, so I can't guarantee that everything works for the fresh example)

@mcandeia
Copy link

@mcandeia

Just to clarify one thing, do I need to set the file system to be the Deno's Compile one? or there are a command that make it work out of the box?

Oh wow, sorry, I'm not a native, so I guess that sentence was ambiguous. 😂 I've confirmed that applying the patch I posted above will render HTML content on your fork.

(However, I've only checked with Postman, so I can't guarantee that everything works for the fresh example)

Oh, I mean, I had to change the following line: https://github.com/deco-cx/edge-runtime/pull/6/files#diff-cce0097be8934b699189157e13e2c8eed2421b37691ab0d0cb25640dcc0f741bL369

is it still necessary or there is a command to link the static file system (like --static *)? To be honest, it would be amazing to have a feature to pass the filesystem inline as a hashmap

{"FILE_PATH": "FILE_CONTENT_BYTES" }

@mcandeia
Copy link

image

Yeah, its happening!

@mcandeia
Copy link

@nyannyacha Want me to open a PR with the modifications you mentioned plus this one? I will be glad to have my first contribution

@nyannyacha
Copy link
Collaborator

@mcandeia

Yes I would be happy for you to do that 😁

But in the case of static fs modification PR, it was written by @andreespirela, so I think it would be better to hear his thoughts first.

@mcandeia
Copy link

Hey @andreespirela any thoughts?

@andreespirela
Copy link
Collaborator Author

@mcandeia We're discussing the how-to internally. It doesn't make sense to disable StaticFS, and changing import.meta.url is not the way to go. More to come... I'm trying to make sure fresh runs smooth.

@mcandeia
Copy link

mcandeia commented Apr 25, 2024

@mcandeia We're discussing the how-to internally. It doesn't make sense to disable StaticFS, and changing import.meta.url is not the way to go. More to come... I'm trying to make sure fresh runs smooth.

If I can share my thoughts: I would love to have a way to pass the filesystem inline as a hashmap. Or even as a "lazy" structure. So we can have two separate things:

  • Eszip having the .ts/.tsx files
  • A lazy filesystem which would use NFS/Block Storage.

This is needed since fresh has build files that needs to be included in the generated eszip but they are not directly imported from the code and they are "lazily loaded"

My 50 cents

@mcandeia
Copy link

mcandeia commented May 3, 2024

Hello guys @andreespirela @nyannyacha, any news?

@laktek laktek marked this pull request as draft May 5, 2024 20:25
@laktek laktek reopened this May 5, 2024
@laktek laktek dismissed their stale review May 5, 2024 21:26

Seems there are some blockers in merging this

@nyannyacha nyannyacha dismissed their stale review May 5, 2024 21:44

static fs is fixed mounted to ./mnt/data currently, so some packages can’t resolve their sub dirs/files using import.meta.url.

@mcandeia
Copy link

mcandeia commented May 10, 2024

Guys @laktek @andreespirela and @nyannyacha, I think the scope of this PR now has changed completely, initially it should be only for supporting JSX import source and I think it was done, just need to fix the missing emitter options as @nyannyacha said.

Ins't better to just create a separate issue for tracking filesystem-related things?

Running fresh projects is out of scope of this PR, it was just an example, supporting JSX is a good start for that

@nyannyacha
Copy link
Collaborator

Guys @laktek @andreespirela and @nyannyacha, I think the scope of this PR now has changed completely, initially it should be only for supporting JSX import source and I think it was done, just need to fix the missing emitter options as @nyannyacha said.

Ins't better to just create a separate issue for tracking filesystem-related things?

Running fresh projects is out of scope of this PR, it was just an example, supporting JSX is a good start for that

Yeah, now that I think about it, this was PR for JSX support.

I think I've gotten away from the point of this PR, as I thought the fresh package case was the main use case.

So I think you're right, we need to separate the static fs issue.

@nyannyacha nyannyacha marked this pull request as ready for review May 16, 2024 03:26
@andreespirela andreespirela merged commit 08ff8af into main May 16, 2024
3 checks passed
@andreespirela andreespirela deleted the support-jsx-import-source branch May 16, 2024 04:10
Copy link

🎉 This PR is included in version 1.52.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support jsxImportSource
4 participants