Skip to content

Commit f2023f2

Browse files
johnjenkinsclaude
andauthored
feat: v5 rename outputs (#6689)
* chore: v5 output target modernization - rename and refactor Major refactor to rename output targets for clarity and elevate sub-outputs to first-class citizens, creating parity between distribution strategies. **Naming changes:** - `dist` → `loader-bundle` (lazy-loaded bundles + loader infrastructure) - `dist-custom-elements` → `standalone` (individual ES modules) - `dist-hydrate-script` → `ssr` (server-side rendering) - `dist-collection` (sub) → `stencil-meta` (first-class, metadata output) - `dist-types` (sub) → `types` (first-class, shared type definitions) **Key changes:** - Updated all constants with v5 names + deprecated v4 aliases - Updated all type definitions (OutputTarget interfaces) - Renamed validator files and updated their logic - Renamed output target implementation directories - Updated type guards with backward-compatible deprecated aliases - Removed collectionDir/typesDir from loader-bundle config - Updated default directories to dist/loader-bundle/, dist/standalone/, etc. **Backward compatibility:** - All deprecated v4 aliases maintained for migration period - Will be removed in v6 **Documentation:** - Added comprehensive "Output Target Modernization" section to V5_PLANNING.md - Updated breaking changes documentation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: add auto-generation logic for types and stencil-meta outputs Implement auto-generation of types and stencil-meta output targets in production builds, elevating them to first-class citizens. **Auto-generation behavior:** - In production builds (!config.devMode), automatically add types and stencil-meta outputs if not explicitly configured by user - User can override by explicitly adding these outputs to their config - Both default to skipInDev: true for optimal dev performance **Implementation:** - Added autoGenerateOutputs() function in validateOutputTargets - Created validate-types.ts for types output validation - Default directories: dist/types/ and dist/stencil-meta/ - Maintains backward compatibility with explicit configs This ensures parity between loader-bundle and standalone outputs, as both now automatically get type definitions in production. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: * chore: remove un-required config options * chore: tests pass * chore: fix knip * chore: new tests * chore: new migration tests * chore: removed --prod and devMode * chore: add transpileStyle inline * chore: * Revert "chore: add transpileStyle inline" This reverts commit 9cf68f4. * chore: change collection / stencil-meta to stencil-rebundle * chore: fixes for package.json checking / validations * chore: rename file extensions - .cjs.js > .cjs, .esm.js > .js * chore: update all 'collection' naming to 'rebundle' * chore: rename dist-custom-elements related files to standalone * chore: update testing * chore: remove 'loader' dir. fix build tests * chore: add esm.js to browser bundle for posterity * chore: main work * chore: tidy codebase * chore: update all tests * chore: fixup tests * chore: better explicit global-style output options * chore: * chore: change all server bundle 'hydrate' refs to 'ssr' * chore: * chore: update default skipInDev behaviour * chore: tidy up * chore: * chore: --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 0834bed commit f2023f2

218 files changed

Lines changed: 8156 additions & 4217 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ This is a major version development branch - breaking changes are ok.
44

55
Read the `./V5_PLANNING.md` file at session start for more details on the goals and plans for this major version. Add and amend this document as needed to keep track of the major version planning and progress.
66

7-
The project has moved to a monorepo structure under `./packages` (using tsdown for bundling) but you can still see the legacy file structure under `./src` (main source / logic), `./scripts` (esbuild bundling) and `./test` (integration / e2e test suite) for reference; most files have the same name. Never change the files in the legacy dirs - they are only for reference and will be deleted once the new structure is fully in place.
8-
97
Always seek to replace code with more modern standards and more modern 3rd party dependencies where possible, and remove older code and dependencies that are no longer needed - but please discuss this with the user before doing so.
108

119
User should not have to ask you for your opinion explicitly. Always evaluate what the user is asking you to do, and voice your concerns before proceeding if you don’t think it's a good idea. If possible, propose a better solution, but you can voice concerns even without one.
1210

1311
This applies even to direct requests to revert or simplify. Still evaluate whether your original approach was better. The user may be missing important context. If there was a solid reasoning you suggested that approach, push back with reasoning instead of silently complying.
1412

15-
Assume any package starting with `@stencil/` is potentially updatable and suggest changes if you think it would be beneficial.
13+
Assume any package starting with `@stencil/` is potentially updatable and suggest changes if you think it would be beneficial.
14+
15+
`as any` is very rarely an acceptable solution. Check with the user before using it, and use better alternatives whenever possible - don't be lazy.
16+
17+
Never commit changes without the user explicitly asking you to. Always ask for confirmation before committing, and provide a clear summary of the changes that will be committed. If the user asks for changes after you’ve provided a summary but before you’ve committed, update the summary to reflect the new changes before asking for confirmation again.
18+
19+
Keep all code comments terse as you can.
20+
21+
To run a unit test `pnpm -F PACKAGE_NAME test TEST_NAME`

V5_PLANNING.md

Lines changed: 104 additions & 489 deletions
Large diffs are not rendered by default.

cspell-wordlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ microtasks
9696
minifier
9797
myapp
9898
mycomponent
99+
mylib
99100
myprop
100101
namespace
101102
nocheck
@@ -170,4 +171,5 @@ jsxs
170171
labelable
171172
lightningcss
172173
cooldown
174+
rebundle
173175
regen

docs/compiler.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,6 @@ describe('compiler', () => {
14241424
{
14251425
"scripts": {
14261426
"build": "node scripts/build.js",
1427-
"build.prod": "node scripts/build.js --prod",
14281427
"build.dev": "node scripts/build.js --dev",
14291428
"watch": "node scripts/build.js --watch"
14301429
}

docs/scripts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ Most Node.js dependencies are externalized except:
239239

240240
```bash
241241
# Development build
242-
npm run build
242+
npm run build -- --dev
243243

244-
# Production build
245-
npm run build -- --prod
244+
# Production build (default)
245+
npm run build
246246

247247
# Watch mode
248248
npm run build -- --watch

knip.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"entry": [
1111
"build/version-utils.ts",
1212
"src/index.d.mts",
13-
"src/runtime/bootstrap-lazy.ts",
14-
"src/server/runner/hydrate-factory.ts",
13+
"src/runtime/bootstrap-loader.ts",
14+
"src/server/runner/ssr-factory.ts",
1515
"src/testing/platform/index.ts",
1616
"src/testing/app-data.ts"
1717
],

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,10 @@
5151
"node": "24.14.0",
5252
"npm": "11.9.0"
5353
},
54-
"packageManager": "pnpm@10.31.0"
54+
"packageManager": "pnpm@10.31.0",
55+
"pnpm": {
56+
"overrides": {
57+
"@stencil/core": "workspace:*"
58+
}
59+
}
5560
}

packages/cli/src/_test_/merge-flags.spec.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from 'vitest';
2-
import type { Config } from '@stencil/core/compiler';
2+
import type { UnvalidatedConfig } from '@stencil/core/compiler';
33

44
import { createConfigFlags, type ConfigFlags } from '../config-flags';
55
import { mergeFlags } from '../merge-flags';
@@ -9,41 +9,23 @@ describe('mergeFlags', () => {
99
return createConfigFlags(overrides);
1010
};
1111

12-
describe('devMode (--dev / --prod)', () => {
13-
it('sets devMode to false when --prod is true', () => {
14-
const config: Config = {};
15-
const flags = createFlags({ prod: true });
16-
17-
const result = mergeFlags(config, flags);
18-
19-
expect(result.devMode).toBe(false);
20-
});
21-
12+
describe('devMode (--dev)', () => {
2213
it('sets devMode to true when --dev is true', () => {
23-
const config: Config = {};
14+
const config: UnvalidatedConfig = {};
2415
const flags = createFlags({ dev: true });
2516

2617
const result = mergeFlags(config, flags);
2718

2819
expect(result.devMode).toBe(true);
2920
});
3021

31-
it('--prod takes precedence over --dev when both are set', () => {
32-
const config: Config = {};
33-
const flags = createFlags({ prod: true, dev: true });
34-
35-
const result = mergeFlags(config, flags);
36-
37-
expect(result.devMode).toBe(false);
38-
});
39-
40-
it('preserves config devMode when neither flag is set', () => {
41-
const config: Config = { devMode: true };
22+
it('does not set devMode when --dev is absent (production is the default)', () => {
23+
const config: UnvalidatedConfig = {};
4224
const flags = createFlags({});
4325

4426
const result = mergeFlags(config, flags);
4527

46-
expect(result.devMode).toBe(true);
28+
expect(result.devMode).toBeUndefined();
4729
});
4830
});
4931

packages/cli/src/config-flags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const BOOLEAN_CLI_FLAGS = [
2121
'open',
2222
'prerender',
2323
'prerenderExternal',
24-
'prod',
2524
'profile',
2625
'serviceWorker',
2726
'serve',

packages/cli/src/merge-flags.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Config } from '@stencil/core/compiler';
1+
import type { UnvalidatedConfig } from '@stencil/core/compiler';
22

33
import type { ConfigFlags } from './config-flags';
44

@@ -7,19 +7,17 @@ import type { ConfigFlags } from './config-flags';
77
*
88
* This function applies command-line flags to the config, with CLI flags
99
* taking precedence over config file values. This is the canonical place
10-
* where flag values are translated into config properties.?
10+
* where flag values are translated into config properties.
1111
*
1212
* @param config The config object (from stencil.config.ts or empty)
1313
* @param flags The parsed CLI flags
1414
* @returns The config with flags merged in
1515
*/
16-
export const mergeFlags = (config: Config, flags: ConfigFlags): Config => {
17-
const merged = { ...config };
16+
export const mergeFlags = (config: UnvalidatedConfig, flags: ConfigFlags): UnvalidatedConfig => {
17+
const merged: UnvalidatedConfig = { ...config };
1818

19-
// --dev / --prod → devMode
20-
if (flags.prod === true) {
21-
merged.devMode = false;
22-
} else if (flags.dev === true) {
19+
// --dev → devMode (production is the default; --dev is the explicit opt-in)
20+
if (flags.dev === true) {
2321
merged.devMode = true;
2422
}
2523

0 commit comments

Comments
 (0)