Sem
Sem
SSolidJS
Created by Sem on 12/24/2023 in #support
ReferenceError: __filename is not defined in ES module scope
I've created an app using solid-start and sucessfuly hosting it on my windows PC with no issue. But then I decided to change host to my Rasberry Pi 4 running ubuntu server. Everything went fine and I've managed to build my app again just like on Windows machine (environment is the same on both machine - node.js 20.8.10, npm 10.1) Build messages are the same, everything goes fine. I'm even able to run dev server on my Pi and connect to it. But when I run solid-start build and then solid-start start I'm getting this message:
file:///home/admin/repos/app/dist/server.js:72828
return !fileExists(swapCase(__filename));
^

ReferenceError: __filename is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/admin/repos/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at isFileSystemCaseSensitive (file:///home/admin/repos/app/dist/server.js:72828:47)
at getNodeSystem (file:///home/admin/repos/app/dist/server.js:72593:47)
at file:///home/admin/repos/app/dist/server.js:73062:21
at file:///home/admin/repos/app/dist/server.js:73069:9
at file:///home/admin/repos/app/dist/server.js:73084:5
at requireTypescript (file:///home/admin/repos/app/dist/server.js:239773:4)
at file:///home/admin/repos/app/dist/server.js:239777:25
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
file:///home/admin/repos/app/dist/server.js:72828
return !fileExists(swapCase(__filename));
^

ReferenceError: __filename is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/admin/repos/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at isFileSystemCaseSensitive (file:///home/admin/repos/app/dist/server.js:72828:47)
at getNodeSystem (file:///home/admin/repos/app/dist/server.js:72593:47)
at file:///home/admin/repos/app/dist/server.js:73062:21
at file:///home/admin/repos/app/dist/server.js:73069:9
at file:///home/admin/repos/app/dist/server.js:73084:5
at requireTypescript (file:///home/admin/repos/app/dist/server.js:239773:4)
at file:///home/admin/repos/app/dist/server.js:239777:25
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
1 replies
SSolidJS
Created by Sem on 11/15/2023 in #support
No known conditions for "./browser" specifier in "msw" package
I'm trying to setup msw with my test environment in vitest and solid. Any idea why is this caused? Code [setup.ts]:
import { HttpResponse, http } from "msw";
import { afterAll, afterEach, beforeAll } from "vitest";

const {setupWorker} = await import("msw/browser");
const genBars = vi.fn(() => HttpResponse.json([]));
const server = setupWorker(
http.get("http://localhost:3000/api/bars/*", genBars)
);
beforeAll(() => {
server.start();
});
afterEach(() => server.resetHandlers());
import { HttpResponse, http } from "msw";
import { afterAll, afterEach, beforeAll } from "vitest";

const {setupWorker} = await import("msw/browser");
const genBars = vi.fn(() => HttpResponse.json([]));
const server = setupWorker(
http.get("http://localhost:3000/api/bars/*", genBars)
);
beforeAll(() => {
server.start();
});
afterEach(() => server.resetHandlers());
2 replies
SSolidJS
Created by Sem on 11/9/2023 in #support
How to handle hydration on client side?
I'm using localstorage to save my local items. Component renders on server if I press F5 and throws an hydration error and it's logically, because server component doesn't have an elements from client sides and it's handled by isServer. But main question: how do I handle this hydration error? How can I manage to synchronize states between server & client?
19 replies