Skip to content

feat: add transformEntry option#225

Draft
yooouuri wants to merge 1 commit intohonojs:mainfrom
yooouuri:main
Draft

feat: add transformEntry option#225
yooouuri wants to merge 1 commit intohonojs:mainfrom
yooouuri:main

Conversation

@yooouuri
Copy link
Copy Markdown

This way, I can "inject" a SSR Vue app.

The implementation, runs the same transformEntry for every entry. Maybe move the entry check from the transform?

Example:

    build({
      entry: 'src/index.ts',
      transformEntry: (code) => {
        const template = readFileSync(join(process.cwd(), 'dist', 'index.html'), 'utf-8')

        const mod = parseModule(`import { render } from './app/entry-server'
${code}
let template = \`${template}\`
app.get('*', async (c) => {
const { html, payload } = await render()
template = template.replace('<!--app-html-->', html)
template = template.replace('<!--payload-->', '<script>window.__payload = ' + JSON.stringify(payload ?? {}) + '</script>')
return c.html(template)
})

export default app`)

        return mod.generate()
      },
      minify: false,
      external: [
        'vue',
        'hono',
        'pinia',
        '@pinia/colada',
      ],
      staticPaths: ['./assets']
    }),

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 10, 2025

⚠️ No Changeset found

Latest commit: 10de75f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant