Skip to content
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

Change project to "type": "module" so we can use pure ESM dependencies #38

Merged
merged 1 commit into from
Feb 1, 2022

Conversation

bensmithett
Copy link
Owner

Closes #28

Also allows upgrading from vite-plugin-mdx to @mdx-js/rollup so we can get MDX 2

@bensmithett bensmithett merged commit 28993dc into main Feb 1, 2022
@bensmithett bensmithett deleted the esmodule branch February 1, 2022 06:00
Comment on lines +2 to +6
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { createServer as createViteServer } from 'vite'

const dir = dirname(fileURLToPath(import.meta.url))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async function prerender () {
const vite = await createViteServer({
server: { middlewareMode: 'ssr' }
})
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of these changes are mostly the same as before. We've just wrapped everything in an async function so that we can create a Vite dev server...

})

try {
const { Renderer } = await vite.ssrLoadModule('/src/entry-server.jsx')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... then use that dev server to access vite.ssrLoadModule.

This is now more consistent with what's happening in our server.js.

import express from 'express'
import { createServer as createViteServer } from 'vite'

const dir = dirname(fileURLToPath(import.meta.url))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export default defineConfig({
plugins: config.plugins,
plugins: [react(), mdx({ rehypePlugins: [rehypeSlug] })],
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need the extra vite.config.server.js due to the changes in prerender.js, so its config has moved in here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant