-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
101 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import fs from 'node:fs/promises'; | ||
|
||
import esbuild from 'esbuild'; | ||
import { createLogger } from './logger.mjs'; | ||
|
||
export async function runBuild({ cliConfig, build, config }) { | ||
const logger = createLogger(undefined, cliConfig); | ||
const { watch } = cliConfig; | ||
|
||
//es6 === es2015, es9 === es2018, es11 === es2020 es13 ===es2022 | ||
try { | ||
const result = await (watch | ||
? esbuild.context(build) | ||
: esbuild.build(build)); | ||
|
||
if (config.analyze && result.metafile) { | ||
logger.log( | ||
await esbuild.analyzeMetafile(result.metafile, { | ||
verbose: cliConfig.verbose, | ||
}), | ||
); | ||
|
||
if (build.outdir) { | ||
await fs.writeFile( | ||
`${build.outdir}/${build.entryNames ?? config.name}.meta.json`, | ||
JSON.stringify(result.metafile), | ||
); | ||
} | ||
} | ||
|
||
if (watch) { | ||
await result.watch(); | ||
} | ||
|
||
return result; | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,44 @@ | ||
import fs from 'node:fs/promises'; | ||
import { createBuildConfig } from './buildConfig.mjs'; | ||
import { createTaskConfig } from './taskConfig.mjs'; | ||
import { runBuild } from './runBuild.mjs'; | ||
|
||
import esbuild from 'esbuild'; | ||
import { createLogger } from './logger.mjs'; | ||
export async function runTask({ cliConfig, merkurConfig, context }) { | ||
const { runTasks } = cliConfig; | ||
let task = { ...merkurConfig.task }; | ||
|
||
export async function runTask({ cliConfig, build, config }) { | ||
const logger = createLogger(undefined, cliConfig); | ||
const { watch } = cliConfig; | ||
|
||
//es6 === es2015, es9 === es2018, es11 === es2020 es13 ===es2022 | ||
try { | ||
const result = await (watch | ||
? esbuild.context(build) | ||
: esbuild.build(build)); | ||
|
||
if (config.analyze && result.metafile) { | ||
logger.log( | ||
await esbuild.analyzeMetafile(result.metafile, { | ||
verbose: cliConfig.verbose, | ||
}), | ||
); | ||
if (runTasks.length !== 0) { | ||
Object.keys(task) | ||
.filter((taskName) => !runTasks.includes(taskName)) | ||
.forEach((taskKey) => { | ||
delete task[taskKey]; | ||
}); | ||
} | ||
|
||
if (build.outdir) { | ||
await fs.writeFile( | ||
`${build.outdir}/${build.entryNames ?? config.name}.meta.json`, | ||
JSON.stringify(result.metafile), | ||
); | ||
} | ||
} | ||
return Object.keys(task).reduce(async (result, key) => { | ||
const definition = task[key]; | ||
|
||
if (watch) { | ||
await result.watch(); | ||
} | ||
const config = await createTaskConfig({ | ||
definition, | ||
merkurConfig, | ||
cliConfig, | ||
context, | ||
}); | ||
const build = await createBuildConfig({ | ||
definition, | ||
config, | ||
merkurConfig, | ||
cliConfig, | ||
context, | ||
}); | ||
result[definition.name] = await runBuild({ | ||
definition, | ||
build, | ||
merkurConfig, | ||
cliConfig, | ||
config, | ||
context, | ||
}); | ||
|
||
return result; | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
}, context.task); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"@merkur/svelte": "0.36.0" | ||
"@merkur/svelte": "0.37.0" | ||
}, | ||
"devDependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"@merkur/uhtml": "0.36.0" | ||
"@merkur/uhtml": "0.37.0" | ||
}, | ||
"devDependencies": {} | ||
} |