-
Notifications
You must be signed in to change notification settings - Fork 644
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: add root project import in import_map #471
Conversation
bfaa386
to
c26a771
Compare
Can you also change the code of the initialized project to make use of |
c26a771
to
31ac7da
Compare
good call. updated 👍 |
I ❤️ Already using this on my projects. Would love to see it become standard. Only confused about the new preact-signals import on fresh 1.1.0 why is it prefixed with @? |
It seems like there is some issue with this change on Windows. I think this is unrelated of this PR |
@xstevenyung I created a new project and added |
Tested and working on macOS! I do believe that this change causes the issue on Windows. Is someone with a Windows machine able to troubleshoot? |
@ayame113, any chance you'd be able to look at this? |
I will look into this later! please wait a little bit! |
Unfortunately I can't reproduce it locally. Can you try rerunning the test and see if this happens again? |
After some debugging, it appears when |
I've been debugging this for several days to get to the cause of the CI failure. I think I may have figured out the cause. I'd like to create a minimal repro example and then post the details here. |
This is due to a 20 year old Windows backwards compatibility feature and a Deno CLI bug related to it. Deno CLI bug for short file namesWindows has a feature called "short file names" for backward compatibility with Windows 95. # Alias for `test dir` is `TESTDI~1`.
C:\Users\ayame\work>dir /x
2023/05/26 15:32 <DIR> .
2023/05/09 08:52 <DIR> ..
2023/05/26 15:35 <DIR> TESTDI~1 test dir Deno CLI has a bug related to short file names. The following example works fine.
Next, move the current directory to the directory with the short file name. This also still works fine. C:\Users\ayame\work\test dir>cd ../TESTDI~1
C:\Users\ayame\work\TESTDI~1>dir
C:\Users\ayame\work\TESTDI~1
2023/05/26 15:44 <DIR> .
2023/05/26 15:32 <DIR> ..
2023/05/26 15:32 38 child.ts
2023/05/26 03:15 43 import-map.json
2023/05/26 03:20 44 parent.ts
C:\Users\ayame\work\TESTDI~1>deno info --import-map=import-map.json ./parent.ts
local: C:\Users\ayame\work\TESTDI~1\parent.ts
emit: C:\Users\ayame\AppData\Local\deno\gen\file\C\Users\ayame\work\TESTDI~1\parent.ts.js
type: TypeScript
dependencies: 1 unique
size: 82B
file:///C:/Users/ayame/work/TESTDI~1/parent.ts (44B)
├── file:///C:/Users/ayame/work/TESTDI~1/child.ts (38B)
└── file:///C:/Users/ayame/work/TESTDI~1/child.ts *
C:\Users\ayame\work\TESTDI~1>deno run --import-map=import-map.json ./parent.ts
hello from child.ts! Now, creating deno.json messes up dependency resolution. C:\Users\ayame\work\TESTDI~1>type deno.json
{
"importMap": "./import-map.json"
}
# ↓`test%20dir/child.ts` and `TESTDI~1/child.ts` are included in dependencies.
C:\Users\ayame\work\TESTDI~1>deno info ./parent.ts
local: C:\Users\ayame\work\TESTDI~1\parent.ts
emit: C:\Users\ayame\AppData\Local\deno\gen\file\C\Users\ayame\work\TESTDI~1\parent.ts.js
type: TypeScript
dependencies: 2 unique
size: 120B
file:///C:/Users/ayame/work/TESTDI~1/parent.ts (44B)
├── file:///C:/Users/ayame/work/test%20dir/child.ts (38B)
└── file:///C:/Users/ayame/work/TESTDI~1/child.ts (38B)
# ↓The hello message will be displayed twice.(bug)
C:\Users\ayame\work\TESTDI~1>deno run ./parent.ts
hello from child.ts!
hello from child.ts! Temporary directory in GitHub ActionsThe temporary directory in GitHub Actions is set to short file name by default. Fresh's Lines 40 to 44 in 7f3fd51
Fresh island detection in testsDuring the test run, inside the temporary directory there is deno.json and import-map with relative path.(
The Lines 367 to 373 in 7f3fd51
Here we have a import Counter1 from "@/islands/Counter.tsx";
import Counter2 from "./islands/Counter.tsx";
Counter1 !== Counter2; // due to bugs. Test failureFailed to find island and the value of variable Telling the puppeteer to click doesn't work the counter. Lines 311 to 316 in 7f3fd51
After that, subsequent tests will also randomly fail because resource cleanup is not done. How to respondAs for the deno.json bug, I'm not familiar with Rust so I'm not sure. ref: rust-lang/rust#59117, rust-lang/rust#76586, Also, a possible workaround on the Fresh side, as described by actions/runner-images#712 (comment), seems to be to override the TMP/TEMP environment variables in the GitHub Actions settings. # .github\workflows\ci.yml
# Workaround for using temporary directory on Windows
# https://github.com/actions/runner-images/issues/712
- name: Set the TMP environment variable (Windows)
if: startsWith(matrix.os, 'windows')
run: echo "TMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
- name: Set the TEMP environment variable (Windows)
if: startsWith(matrix.os, 'windows')
run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV There are the result of debugging on https://github.com/ayame113/fresh/commits/win-failed-test branch. |
Excellent troubleshooting, @ayame113! Very helpful. I've applied the workaround to CI. Now, we're running into an issue caused by |
No description provided.