Closed Zageron closed 3 years ago
@Zageron can you please try hq --verbose build
it seems like for windows it can't determine project root in build mode. I still have no windows machine and can't properly debug it. Will appreciate your help.
Wrong assumption. For some reasons request path contains disk letter L:\
in your case. Not sure how it gets there. @Zageron will you be able to debug crawl/index.mjs
and watch queue
variable?
Just in case - check the raw output of index.html
in dist
folder if it contains disk letter L:\
there - the problem is dipper.
@Zageron I tried to hack it, please try hq@0.0.27
If you would be able to write up a quick set of dev instructions on how you have hq set up for debugging, I'd certainly be able to try debugging for future issues as well. Do you do much beyond having the project linked as a local dependency? I only have limited experience debugging my own dependencies, so some instructions would be appreciated, if possible.
I'll give that version a try a little later today, thanks for your attempt! :D
Thanks! If you have vscode - there is a launch.json
that allow to run hq
and serve hq
or build hq
. You can change launch config to serve your project instead and put breakpoints on right in the code. Or you can do npm link and just debug with good old console.log
.
I've found an error in my workaround and publish hq@0.0.28
Here's my build output. I'll look at debugging in a bit.
Verbose flag seems to be broken now.
PS L:\git\zageron\tinkering> hq build
(c) hqjs @ 0.0.28
Start time: 0.6 s
Visit http://localhost:8080
or http://172.28.64.1:8080 within local network
⬇️ /index.html
� /index.html
⬇️ /L:/git/zageron/tinkering/stylesheets/style.scss
⬇️ /L:/git/zageron/tinkering/index.ts
❌ Error /L:/git/zageron/tinkering/stylesheets/style.scss: File /L:/git/zageron/tinkering/stylesheets/style.scss not found
NotFoundError: File /L:/git/zageron/tinkering/stylesheets/style.scss not found
at Object.throw (C:\Users\Zageron\AppData\Roaming\nvm\v12.18.4\node_modules\@hqjs\hq\node_modules\koa\lib\context.js:97:11)
at resolveSrc (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/middlewares/resolve-path.mjs:128:21)
❌ Error /L:/git/zageron/tinkering/index.ts: File /L:/git/zageron/tinkering/index.ts not found
NotFoundError: File /L:/git/zageron/tinkering/index.ts not found
at Object.throw (C:\Users\Zageron\AppData\Roaming\nvm\v12.18.4\node_modules\@hqjs\hq\node_modules\koa\lib\context.js:97:11)
at resolveSrc (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/middlewares/resolve-path.mjs:128:21)
Error: Unable to build /L:/git/zageron/tinkering/stylesheets/style.scss: Not Found
at build (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:163:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async request (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:115:5)
Error: Unable to build /L:/git/zageron/tinkering/index.ts: Not Found
at build (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:163:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async request (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:115:5)
⬇️ /index.html
� /index.html
⬇️ /L:/git/zageron/tinkering/index.ts
❌ Error /L:/git/zageron/tinkering/index.ts: File /L:/git/zageron/tinkering/index.ts not found
NotFoundError: File /L:/git/zageron/tinkering/index.ts not found
at Object.throw (C:\Users\Zageron\AppData\Roaming\nvm\v12.18.4\node_modules\@hqjs\hq\node_modules\koa\lib\context.js:97:11)
at resolveSrc (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/middlewares/resolve-path.mjs:128:21)
Error: Unable to build /L:/git/zageron/tinkering/index.ts: Not Found
at build (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:163:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async request (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:115:5)
� Bundling for old browsers
⚠️ Build completed with errors:
� Error: Unable to build /L:/git/zageron/tinkering/stylesheets/style.scss: Not Found
� Error: Unable to build /L:/git/zageron/tinkering/index.ts: Not Found
� Error: Unable to build /L:/git/zageron/tinkering/index.ts: Not Found
PS L:\git\zageron\tinkering>
Extra verbose bit
PS L:\git\zageron\tinkering> hq --verbose build
(c) hqjs @ 0.0.28
Start time: 0.5 s
Visit http://localhost:8080
or http://172.28.64.1:8080 within local network
| hq root : C:\Users\Zageron\AppData\Roaming\nvm\v12.18.4\node_modules\@hqjs\hq
| root : L:\git\zageron\tinkering
| src : src
| certs :
| babelrc : undefined
| postcssrc : undefined
| posthtmlrc : undefined
⬇️ /--verbose
� USER AGENT hq 1.0 for module
❌ Error /--verbose: File /--verbose not found
NotFoundError: File /--verbose not found
at Object.throw (C:\Users\Zageron\AppData\Roaming\nvm\v12.18.4\node_modules\@hqjs\hq\node_modules\koa\lib\context.js:97:11)
at resolveSrc (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/middlewares/resolve-path.mjs:128:21)
Error: Unable to build /--verbose: Not Found
at build (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:163:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async request (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:115:5)
at async makeBuild (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:63:3)
at async default (file:///C:/Users/Zageron/AppData/Roaming/nvm/v12.18.4/node_modules/@hqjs/hq/crawl/index.mjs:38:3)
Right, verbose won't work with build, it treats it as an argument for build. I have to fix it.
That is super strange that full path is in request path /L:/git/zageron/tinkering/index.ts
. I'll appreciate help with debugging.
How do I specify a different project from launch?
You should specify cwd
which is absolute path to your project in launch configuration.
For example
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch HQ",
"program": "${workspaceFolder}/index.mjs",
"runtimeArgs": [
"--experimental-modules",
"--experimental-json-modules"
]
},
{
"type": "node",
"request": "launch",
"name": "Launch HQ Build",
"program": "${workspaceFolder}/index.mjs",
"runtimeArgs": [
"--experimental-modules",
"--experimental-json-modules"
],
"args": [
"build"
],
"cwd": "/Users/yuri/web/hqjs.github.io"
}
]
}
Seems to be a problem with:
export const pathToURL = filePath => url.pathToFileURL(filePath).href.slice('file:///'.length).replace(/^[a-zA-Z]:/, '');
// Trying 3 slashes
const tempPath0 = urlModule.pathToFileURL(rpath);
const tempPath1 = tempPath0.href; // 'file:///L:/git/zageron/tinkering/stylesheets/style.scss'
const tempPath2 = tempPath1.slice('file:///'.length); // 'L:/git/zageron/tinkering/stylesheets/style.scss'
const tempPath3 = tempPath2.replace(/^[a-zA-Z]:/, ''); // '/git/zageron/tinkering/stylesheets/style.scss'
// Result with 2 slashes
const tempPath0 = urlModule.pathToFileURL(rpath);
const tempPath1 = tempPath0.href; // 'file:///L:/git/zageron/tinkering/stylesheets/style.scss'
const tempPath2 = tempPath1.slice('file://'.length); // '/L:/git/zageron/tinkering/stylesheets/style.scss'
const tempPath3 = tempPath2.replace(/^[a-zA-Z]:/, ''); // '/L:/git/zageron/tinkering/stylesheets/style.scss'
@Zageron pathToURL
works in other places. Do you understand why disk letter appears in link paths? queue
suppose to have all links collected from html, js and css and I have no idea why disk letter appears there. I added pathToURL
to line 123
of crawl/index.mjs
as a hack, but I don't understand how filesystem path gets there? Can you please check how queue
variable changes after index.html
parsing? May be put some breakpoints to crawl/index.mjs
and crawl/html.mjs
.
This is what I get on linux:
rpath and fpath are both relative paths: 'stylesheets/style.scss'
Using the pathToFileUrl function I get this: 'file:///mnt/l/git/zageron/tinkering/stylesheets/style.scss'
When it finishes it returns:
tfPath = '/stylesheets/style.css'
trPath = '/mnt/l/git/zageron/tinkering/stylesheets/style.scss'
The queue stuff in htlm.mjs is always the relative path from what I can see. ex. '/stylesheets/style.css'
Windows would always return the drive letter because link paths in windows always include the drive letter.
(For example this is a functioning link in windows:
file:///C:\Users\Zageron\.vscode\extensions\jacqueslucke.blender-development-0.0.12
Here's a bit of experimentation:
await Promise.allSettled(Array.from(queue.entries())
.map(([ fpath, rpath ]) => {
const tempPath0 = urlModule.pathToFileURL(rpath);
const tempPath1 = tempPath0.href;
const tempPath2 = tempPath1.slice('file://'.length);
const uPath = tempPath1.slice('file:///'.length);
const tempPath3 = tempPath2.replace(/^[a-zA-Z]:/, '');
//const uPath = pathToURL(rpath);
const trPath = uPath.startsWith(baseURI) ?
uPath.slice(baseURI.length) :
!uPath.startsWith('/') ?
path.resolve('/', uPath) :
uPath;
const tfPath = fpath.startsWith(baseURI) ?
fpath.slice(baseURI.length) :
!fpath.startsWith('/') ?
path.resolve('/', fpath) :
fpath;
return [ tfPath, trPath ];
})
The result of trPath is correct with this: 'L:\\git\\zageron\\tinkering\\stylesheets\\style.scss'
But the tfPath is resolving incorrectly: 'L:\\stylesheets\\style.css'
This is definitely an assumption of similar behaviour between linux and windows. Where /
is the root of a link in linux, but the drive letter is the root of a link in windows. Not entirely sure how to resolve this, the variable names in this code block aren't descriptive enough for me to understand what they're supposed to be, so.
Hope this helps.
Thanks! I will remove urlToPath
- it was bad idea. How drive letter get into a path? It is the link from index.html
so it should be either relative or absolute from the project root, but not from system root. Can you please check what is the output for index.html
if you remove urlToPath
?
fPath
represents file path while rPath
- should be request path.
Does queue
in index.html
on Windows also includes /stylesheets/style.css
? Or it has drive letter?
iirc it had no drive letter in queue. Drive letter was only added after calling uriToPath, and/or resolve function.
In your original post there was no pathToURL
present, but there was still a drive letter. Can you please remove pathToURL
or just update to latest and check where this letter appears? It not suppose to be there and that is what cause the problem.
It's coming from the path.resolve('/', rpath) calls.
Thanks! That helps a lot! I'll prepare a fix during next week and let you know.
@Zageron I pushed an update to master without release. Can you please test if it fixes the problem with windows build?
Actually published it as hq@0.0.30
Closed due to inactivity, should be fixed by now
Thank you apologies for inactivity I've been over in rust land, as well as working and holidaying.
Thanks for resolving this for me!
No worries, hope it is working, if not feel free to reopen an issue or create a new one. Merry Christmas and happy new year!
Likely the same path issue as before. Luckily ubuntu builds still work so I can just build over there. :)
Ubuntu
Windows