Use module.createRequire instead fs.readFile for import package.json

This commit is contained in:
草鞋没号 2022-01-07 08:44:55 +08:00
parent ac55656eca
commit 16917388d1

View File

@ -1,14 +1,14 @@
process.env.NODE_ENV = 'development'
import { readFileSync } from 'fs'
import { join } from 'path'
import electron from 'electron'
import { spawn } from 'child_process'
import { createRequire } from 'module'
import { createServer, build as viteBuild } from 'vite'
import chalk from 'chalk'
const TAG = chalk.bgGreen(' dev.mjs ')
const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'))
const require = createRequire(import.meta.url)
const pkg = require('../package.json')
/**
* @param {{ name: string; configFile: string; writeBundle: import('rollup').OutputPlugin['writeBundle'] }} param0