-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular-devkit/build-angular): add
ssr
option in application …
…builder This commit adds an `ssr` option to the application builder, this can be either a `boolean` or an `object` with an `entryPoint` property. In the future, server bundles will only be emitted when the ssr option is truthy, as unlike SSR, SSG and AppShell do not require the server bundles to be written to disk.
- Loading branch information
1 parent
a0a2c7a
commit e6b3774
Showing
8 changed files
with
148 additions
and
46 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
58 changes: 58 additions & 0 deletions
58
packages/angular_devkit/build_angular/src/builders/application/tests/options/ssr_spec.ts
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,58 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { buildApplication } from '../../index'; | ||
import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { | ||
beforeEach(async () => { | ||
await harness.modifyFile('src/tsconfig.app.json', (content) => { | ||
const tsConfig = JSON.parse(content); | ||
tsConfig.files ??= []; | ||
tsConfig.files.push('main.server.ts', 'server.ts'); | ||
|
||
return JSON.stringify(tsConfig); | ||
}); | ||
|
||
await harness.writeFile('src/server.ts', `console.log('Hello!');`); | ||
}); | ||
|
||
describe('Option: "ssr"', () => { | ||
it('uses a provided TypeScript file', async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
server: 'src/main.server.ts', | ||
ssr: { | ||
entry: 'src/server.ts', | ||
}, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBeTrue(); | ||
|
||
harness.expectFile('dist/main.server.mjs').toExist(); | ||
harness.expectFile('dist/server.mjs').toExist(); | ||
}); | ||
|
||
it('resolves an absolute path as relative inside the workspace root', async () => { | ||
await harness.writeFile('file.mjs', `console.log('Hello!');`); | ||
|
||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
server: 'src/main.server.ts', | ||
ssr: { | ||
entry: '/file.mjs', | ||
}, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBeTrue(); | ||
harness.expectFile('dist/server.mjs').toExist(); | ||
}); | ||
}); | ||
}); |
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