-outfile.js
+outfile.cjs
# Logs
logs
const pkg = { name: packageName, version: '0.0.0' }
fs.writeFileSync(path.resolve(root, 'package.json'), JSON.stringify(pkg, null, 2))
- const templateRoot = new URL('./template', import.meta.url).pathname
+ // todo:
+ // work around the esbuild issue that `import.meta.url` cannot be correctly transpiled
+ // when bundling for node and the format is cjs
+ // const templateRoot = new URL('./template', import.meta.url).pathname
+ const templateRoot = path.resolve(__dirname, 'template')
const render = function render(templateName) {
const templateDir = path.resolve(templateRoot, templateName)
renderTemplate(templateDir, root)
"create-vue": "outfile.js"
},
"files": [
- "outfile.js",
+ "outfile.cjs",
"template"
],
"engines": {
"scripts": {
"prepare": "husky install",
"format": "prettier --write .",
- "build": "esbuild --bundle index.js --format=esm --platform=node --outfile=outfile.js",
+ "build": "esbuild --bundle index.js --format=cjs --platform=node --outfile=outfile.cjs",
"snapshot": "node snapshot.js",
"pretest": "run-s build snapshot",
"test": "node test.js",
import { spawnSync } from 'child_process'
-const bin = new URL('./outfile.js', import.meta.url).pathname
+const bin = new URL('./outfile.cjs', import.meta.url).pathname
const playgroundDir = new URL('./playground/', import.meta.url).pathname
function createProjectWithFeatureFlags(flags) {