-
Notifications
You must be signed in to change notification settings - Fork 31
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
use pathe instead of node:path in runtime code #126
base: main
Are you sure you want to change the base?
Conversation
💯
|
Pretty sure we can not revert // node_modules/.deno/[email protected]/node_modules/telefunc/dist/cjs/node/server/runTelefunc/assertNamingConvention.js
var require_assertNamingConvention = __commonJS({
"node_modules/.deno/[email protected]/node_modules/telefunc/dist/cjs/node/server/runTelefunc/assertNamingConvention.js"(exports) {
...
function assertCollocation(telefuncFilePath, appRootDir, exportValue) {
appRootDir = appRootDir || exportValue._appRootDir || null;
if (!appRootDir)
return;
let fs2;
let path;
const req = __require;
try {
fs2 = req("node:fs");
path = req("node:path");
} catch (_a) {
return;
} I guess cloudflare is shiming |
The question here is: how can we bypass the static analysis of bundlers? That's actually why the code uses One trick, for example, is to |
Well, with the current PRs state it actually works on cloudflare, just tested it. |
Cloudflare doesn't even have the notion of a filesystem so it won't work anyways. It's best we avoid |
This is an issue that should be fixed anyways, regardless of this PR. So we might as well fix it now. |
Not sure what you mean, if I deploy my worker on cloudflare with telefunc from this PR it actually works fine. |
It bloats the worker size
…On Tue 5. Nov 2024 at 14:57, samuba ***@***.***> wrote:
Cloudflare doesn't even have the notion of a filesystem so it won't work
anyways. It's best we avoid node:fs and node:path/pathe to be included in
edge environment such as Cloudflare workers.
Not sure what you mean, if I deploy my worker on cloudflare with telefunc
from this PR it actually works fine.
—
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVQRXHHV3GMRR6GEW5JN3Z7DFC7AVCNFSM6AAAAABRGKKCZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJXGI2DQNBXGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
For context: My project is sveltekit with cloudflare adapter. It is expected that the build output is one big worker.js file because the cloudflare adapter can not output multiple workers, just one, it's a known limitation.
Are you saying |
In theory, yes, that would be the best. But in practice, as your rightly point out, to it isn't (easily) achievable. That said, it should be possible (and in my experience relatively easy) to ensure that The bottom line is that |
Idea: const require_ = globalThis['re' + (1 < 2 ? 'quire' : '')]
require_('node:path') But I'm thinking that |
Are you implying that the implementation of |
Ah, I was wrong: your bundler actually doesn't bundle So if we revert the changes to If we then apply my other comments then I believe we can remove the |
If we do that we import from I still think pathe is a good option. It's tiny and after treeshaking there wont be much left. |
That's surprising: the try-catch block swallows the error. Are you sure the error is shown? Anyways, if we replace
I ain't categorically against it, but if we can have a couple of lines instead of using |
fixes #117