Skip to content

Commit

Permalink
feat: do not run assets bundler when disabled in rc file (#4429)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Feb 24, 2024
1 parent c0a86f3 commit be6ca03
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/internal_helpers.ts
Expand Up @@ -49,6 +49,10 @@ function generateJsFilenames(filename: string) {
export async function detectAssetsBundler(
app: ApplicationService
): Promise<RcFile['assetsBundler']> {
if (app.rcFile.assetsBundler === false) {
return false
}

if (app.rcFile.assetsBundler) {
return app.rcFile.assetsBundler
}
Expand Down
47 changes: 46 additions & 1 deletion tests/commands/serve.spec.ts
Expand Up @@ -222,7 +222,11 @@ test.group('Serve command', () => {
)
})

test('do not attempt to serve assets when --no-assets flag is used', async ({ fs, cleanup }) => {
test('do not attempt to serve assets when --no-assets flag is used', async ({
assert,
fs,
cleanup,
}) => {
await fs.create('bin/server.js', '')
await fs.create(
'node_modules/ts-node/package.json',
Expand Down Expand Up @@ -253,6 +257,47 @@ test.group('Serve command', () => {
cleanup(() => command.devServer.close())
await command.exec()
await sleep(600)

assert.notExists(
ace.ui.logger.getLogs().find((log) => {
return log.message.match(/starting "vite" dev server/)
})
)
})

test('do not launch assets bundler when disabled in rc file', async ({ fs, cleanup, assert }) => {
await fs.create('bin/server.js', '')
await fs.create(
'node_modules/ts-node/package.json',
JSON.stringify({
name: 'ts-node',
exports: {
'./esm': './esm.js',
},
})
)
await fs.create('node_modules/ts-node/esm.js', '')
await fs.create('vite.config.js', '')

const ace = await new AceFactory().make(fs.baseUrl, {
importer: (filePath) => {
return import(filePath)
},
})

ace.app.rcFile.assetsBundler = false
ace.ui.switchMode('raw')

const command = await ace.create(Serve, ['--no-clear'])
cleanup(() => command.devServer.close())
await command.exec()
await sleep(600)

assert.notExists(
ace.ui.logger.getLogs().find((log) => {
return log.message.match(/starting "vite" dev server/)
})
)
})

test('correctly pass hooks to the DevServer', async ({ assert, fs, cleanup }) => {
Expand Down

0 comments on commit be6ca03

Please sign in to comment.