Skip to content

Commit

Permalink
revert: remove unused generated dist/server/package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Feb 16, 2022
1 parent 408670a commit b72e908
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions telefunc/node/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { transform } from './transform'
import { build } from './build'
// import { importBuild } from 'vite-plugin-import-build'
// import { getImportBuildCode } from './getImportBuildCode'
import { packageJsonFile } from './packageJsonFile'
import { retrieveDevServer } from './retrieveDevServer'
import type { Plugin } from 'vite'
import { distLinkOn, distLinkOff } from './distLink'
Expand All @@ -27,6 +28,7 @@ function plugin(): Plugin[] {
transform(),
build(),
//importBuild(getImportBuildCode()),
packageJsonFile(),
distLinkOn(),
]
}
37 changes: 37 additions & 0 deletions telefunc/node/vite/packageJsonFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* We create a file `dist/server/package.json` to support ESM users.
* Explanation: https://github.com/brillout/vite-plugin-ssr/blob/7b499a94780fa33f7931d2bcd0aeb2eb2aac0274/vite-plugin-ssr/node/plugin/packageJsonFile.ts#L2-L7
*/

import type { Plugin } from 'vite'
import { assert } from '../utils'
import { isSSR_config } from './utils'

export { packageJsonFile }

function packageJsonFile(): Plugin {
let ssr: boolean
return {
name: 'telefunc:packageJsonFile',
apply: 'build',
configResolved(config) {
ssr = isSSR_config(config)
},
generateBundle(_options, bundle) {
assert(typeof ssr === 'boolean')
if (!ssr) return
const fileName = 'package.json'
//if (!bundle[fileName]) {
this.emitFile({
fileName,
type: 'asset',
source: getPackageJsonContent(),
})
//}
},
} as Plugin
}

function getPackageJsonContent(): string {
return '{ "type": "commonjs" }'
}

0 comments on commit b72e908

Please sign in to comment.