Skip to content

Commit

Permalink
feat(dist-custom-elements-bundle): add deprecation warning (#3167)
Browse files Browse the repository at this point in the history
in preparation to deprecate the `dist-custom-elements-bundle` output
target, fire a warning when the build process begins if the output target
is found in a user's `stencil.config.ts`
  • Loading branch information
willmartian authored Dec 6, 2021
1 parent f164407 commit c7b07c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compiler/config/outputs/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as d from '../../../declarations';
import { buildError } from '@utils';
import { VALID_TYPES } from '../../output-targets/output-utils';
import { buildError, buildWarn } from '@utils';
import { DIST_CUSTOM_ELEMENTS_BUNDLE, VALID_TYPES } from '../../output-targets/output-utils';
import { validateCollection } from './validate-collection';
import { validateCustomElement } from './validate-custom-element';
import { validateCustomOutput } from './validate-custom-output';
Expand All @@ -22,6 +22,10 @@ export const validateOutputTargets = (config: d.Config, diagnostics: d.Diagnosti
err.messageText = `Invalid outputTarget type "${
outputTarget.type
}". Valid outputTarget types include: ${VALID_TYPES.map((t) => `"${t}"`).join(', ')}`;
} else if (outputTarget.type === DIST_CUSTOM_ELEMENTS_BUNDLE) {
// TODO(STENCIL-260): Remove this check when the 'dist-custom-elements-bundle' is removed
const warning = buildWarn(diagnostics);
warning.messageText = `dist-custom-elements-bundle is deprecated and will be removed in a future major version release. Use "dist-custom-elements" instead. If "dist-custom-elements" does not meet your needs, please add a comment to https://github.com/ionic-team/stencil/issues/3136.`;
}
});

Expand Down
13 changes: 13 additions & 0 deletions src/compiler/config/test/validate-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ describe('validation', () => {
expect(validated.diagnostics).toHaveLength(1);
});

it('should warn when dist-custom-elements-bundle is found', () => {
userConfig.outputTargets = [
{
type: 'dist-custom-elements-bundle',
},
];
const validated = validateConfig(userConfig);
expect(validated.diagnostics).toHaveLength(1);
expect(validated.diagnostics[0].messageText).toBe(
'dist-custom-elements-bundle is deprecated and will be removed in a future major version release. Use "dist-custom-elements" instead. If "dist-custom-elements" does not meet your needs, please add a comment to https://github.com/ionic-team/stencil/issues/3136.'
);
});

it('should default outputTargets with www', () => {
const { config } = validateConfig(userConfig);
expect(config.outputTargets.some((o) => o.type === 'www')).toBe(true);
Expand Down

0 comments on commit c7b07c6

Please sign in to comment.