Closed childrentime closed 1 year ago
Name | Link |
---|---|
Latest commit | 1168261f32c83e88ebca10835abb281b8a6a2c76 |
Latest deploy log | https://app.netlify.com/sites/vite-react-ssg/deploys/653b598c961dcd00084aa79f |
Deploy Preview | https://deploy-preview-4--vite-react-ssg.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
The current version actually has common js products, but the cli file executed by default is in esm format. I think I can add a common js cli file.
@childrentime Hi, You could write a similar script to replace '.mjs' with '.cjs'.
https://github.com/Daydreamer-riri/vite-react-ssg/blob/main/bin/vite-react-ssg.js
I'll give it a try. I'll see if it can run normally under the CommonJS (cjs) format, and then figure out how to make it work properly with ECMAScript Modules (esm) as well.
@Daydreamer-riri well. This can't work either. Because devcert use dynamic require and rollup can't handle it.
Anyway, if you use devcert in a normal vite project, it just works well.
I can't understand why __dirname
appears in the ESM (ECMAScript Module) bundle result . this sucks
@Daydreamer-riri well. This can't work either. Because devcert use dynamic require and rollup can't handle it. Anyway, if you use devcert in a normal vite project, it just works well.
I can't understand why
__dirname
appears in the ESM (ECMAScript Module) bundle result . this sucks
Can you provide a repository for me to debug this problem?
@Daydreamer-riri You can directly check out this pr, and install deps.
OK, I will check this problem as soon as possible.
I just found out that Rollup does not convert __dirname
by default. This plugin is needed: https://www.npmjs.com/package/rollup-plugin-node-globals.
But this package might be a bit outdated. Also, I tried const devcert = require('devcert');
, the output in CommonJS can run normally, but the output in ESM still doesn't work. The best approach might be to modify the source code and packaging method of the devcert
package.
devcert
uses __dirname
in its code, so its code is not bindable and it needs to maintain its own directory structure. I think we can allow https configuration to make vite-react-ssg
support https at development time and state that in the documentation.
Users can install devcert
on their own and configure it in vite.config.js
.
Never mind. I forked the devcert library and repackaged its ESM and CJS outputs using tsup. Now we can enable local HTTPS through the https option🎉🎉🎉.
@Daydreamer-riri cc
Great! 🎉🎉🎉
One thing, I think we can use viteconfig.server.https directly as the configuration item, And state this in the documentation.
What do you think?
You're right, I'll make the changes tomorrow
@Daydreamer-riri cc
Great! Thank you for your contribution.
Hi @childrentime , I encountered a question:
Is there anything I missed?
system: Ubuntu 22.04.1 LTS WSL2
@Daydreamer-riri I haven't tested its usability on the Linux platform, only tested macos. I just found that there are conditional statements in Linux that use dynamic require. I will submit another PR to modify it.
Or you can upgrade the package @childrentime/devcert to version 1.2.8. I've just addressed this issue in this version.
@Daydreamer-riri 哥,携程还招人不,捞我一个😭
@Daydreamer-riri 哥,携程还招人不,捞我一个😭
你给我发个邮件?我们邮件联系,我问一下我这边的
This is reproducible #2 , which might be due to the devcert package only supporting commonjs and not esm. I'm not very familiar with unbuild. Is there a way to convert it, or do I need to fork a version of the devcert package that supports esm?