-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1195 from serlo/fix-start-command
chore: Use esbuild for start command
- Loading branch information
Showing
16 changed files
with
74 additions
and
120 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
Binary file removed
BIN
-13.2 KB
.yarn/cache/@zerollup-ts-helpers-npm-1.7.18-fa39b91899-6ad5cc3501.zip
Binary file not shown.
Binary file removed
BIN
-22.6 KB
.yarn/cache/@zerollup-ts-transform-paths-npm-1.7.18-14319406c9-2a3b258222.zip
Binary file not shown.
Binary file removed
BIN
-16.1 KB
.yarn/cache/babel-plugin-import-graphql-npm-2.8.1-2a6a1b69ec-8e156d514c.zip
Binary file not shown.
Binary file removed
BIN
-12.6 KB
.yarn/cache/babel-plugin-module-resolver-npm-5.0.0-67eb48a53b-d6880e49fc.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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,44 @@ | ||
import { spawn, ChildProcess } from 'child_process' | ||
import * as esbuild from 'esbuild' | ||
|
||
import { getEsbuildOptions, loadSourceAndOutput } from './build' | ||
|
||
await main() | ||
|
||
async function main() { | ||
const { source, outfile } = loadSourceAndOutput() | ||
|
||
let serverProcess: ChildProcess | null = null | ||
|
||
const startServerPlugin: esbuild.Plugin = { | ||
name: 'startServer', | ||
setup(build) { | ||
build.onStart(() => { | ||
// eslint-disable-next-line no-console | ||
console.info('\nINFO: (Re)start of process...') | ||
}) | ||
|
||
build.onEnd(({ errors }) => { | ||
if (errors.length > 0) { | ||
// eslint-disable-next-line no-console | ||
console.info('INFO: Process will not be (re)started due to error.') | ||
|
||
return | ||
} | ||
|
||
if (serverProcess) serverProcess.kill() | ||
|
||
serverProcess = spawn('node', [outfile], { stdio: 'inherit' }) | ||
}) | ||
}, | ||
} | ||
|
||
const { plugins = [], ...options } = getEsbuildOptions(source, outfile) | ||
|
||
const ctx = await esbuild.context({ | ||
...options, | ||
plugins: [...plugins, startServerPlugin], | ||
}) | ||
|
||
await ctx.watch({}) | ||
} |
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