Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nitedani committed Dec 12, 2023
1 parent ee543e4 commit 41638c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 14 additions & 0 deletions vike/node/plugin/plugins/serverEntryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Plugin } from 'vite'
import type { ConfigVikeUserProvided } from '../../../shared/ConfigVike.js'
import { getGlobalObject } from '../utils.js'
import { standalonePlugin } from './standalonePlugin.js'
import path from 'path'

const globalObject = getGlobalObject('serverEntryPlugin.ts', {
serverEntry: ''
Expand All @@ -19,6 +20,7 @@ function serverEntryPlugin(configVike?: ConfigVikeUserProvided): Plugin[] {
return []
}
globalObject.serverEntry = serverEntry
let root = ''

const serverEntryProdPlugin = (): Plugin => {
return {
Expand All @@ -34,8 +36,20 @@ function serverEntryPlugin(configVike?: ConfigVikeUserProvided): Plugin[] {
rollupOptions: {
input: { index: serverEntry }
}
},
vitePluginImportBuild: {
_disableAutoImporter: true
}
}
},
configResolved(config) {
root = config.root
},
renderChunk(code, chunk) {
if (chunk.facadeModuleId === path.posix.join(root, serverEntry)) {
code = "import './importBuild.cjs'\n" + code
}
return code
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions vike/node/plugin/plugins/standalonePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ function standalonePlugin({ serverEntry }: { serverEntry: string }): Plugin {
// ../../node_modules/@brillout/picocolors/package.json:10:2:
// 10 │ "sideEffects": false,
noExternal: ['@brillout/picocolors']
},
vitePluginImportBuild: {
_disableAutoImporter: true
}
}
},
Expand All @@ -64,7 +61,6 @@ function standalonePlugin({ serverEntry }: { serverEntry: string }): Plugin {

renderChunk(code, chunk) {
if (chunk.facadeModuleId === path.posix.join(root, serverEntry)) {
code = "import './importBuild.cjs'\n" + code
builtEntryAbs = path.posix.join(outDirAbs, chunk.fileName)
}
return code
Expand Down

0 comments on commit 41638c5

Please sign in to comment.