-
Notifications
You must be signed in to change notification settings - Fork 143
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 #2233 from embroider-build/builder-api
Add a builder API to @embroider/compat to support ember commands like `ember test`
- Loading branch information
Showing
5 changed files
with
41 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { spawn } from 'child_process'; | ||
|
||
export function buildOnce(outputPath: string, emberEnv: 'development' | 'test' | 'production'): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn( | ||
`npx vite build --outDir ${outputPath} --mode ${emberEnv === 'production' ? 'production' : 'development'}`, | ||
{ | ||
cwd: process.cwd(), | ||
shell: true, | ||
stdio: 'inherit', | ||
env: { ...process.env }, | ||
} | ||
); | ||
child.on('exit', code => (code === 0 ? resolve() : reject(new Error('vite build failed')))); | ||
}); | ||
} |
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,10 +1,11 @@ | ||
'use strict'; | ||
|
||
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); | ||
const { maybeEmbroider } = require('@embroider/test-setup'); | ||
const { compatBuild } = require('@embroider/compat'); | ||
|
||
module.exports = function (defaults) { | ||
module.exports = async function (defaults) { | ||
const { buildOnce } = await import('@embroider/vite'); | ||
let app = new EmberApp(defaults, {}); | ||
|
||
return maybeEmbroider(app); | ||
return compatBuild(app, buildOnce); | ||
}; |