natemoo-re / microsite

Do more with less JavaScript. Microsite is a smarter, performance-obsessed static site generator powered by Preact and Snowpack.
https://npm.im/microsite
MIT License
878 stars 16 forks source link

getStaticProps + node builtins + dev server fails #132

Open mxmul opened 3 years ago

mxmul commented 3 years ago

I've been trying to statically generate pages with getStaticProps and getStaticPaths, but the dev server crashes whenever I try to import fs; production builds work just fine.

 ❱ yarn start
yarn run v1.22.10
warning package.json: No license field
$ microsite
[snowpack] ! building dependencies...
~/snowpack/esinstall/lib/entrypoints.js:168
        throw new Error(`Package "${dep}" not found. Have you installed it? ${depManifestLoc ? depManifestLoc : ''}`);
              ^

Error: Package "fs" not found. Have you installed it?
    at Object.resolveEntrypoint (~/snowpack/esinstall/lib/entrypoints.js:168:15)
    at resolveWebDependency (~/snowpack/esinstall/lib/index.js:89:31)
    at Object.install (~/snowpack/esinstall/lib/index.js:203:36)
    at Object.run (~/snowpack/snowpack/lib/sources/local-install.js:43:43)
    at installDependencies (~/snowpack/snowpack/lib/sources/local.js:54:49)
    at async Object.prepare (~/snowpack/snowpack/lib/sources/local.js:109:35)
    at async startServer (~/snowpack/snowpack/lib/commands/dev.js:278:27)
    at async dev (file://~/microsite/examples/root/node_modules/microsite/dist/cli/microsite-dev.js:57:22)

I've tested this with the latest SHA of both microsite@1.1.0 and snowpack, and get the same result. You should be able to repro by running npm start in this example project: ./examples/root

natemoo-re commented 3 years ago

Just ran into some weirdness around builtins myself. I'm taking a look!