Skip to content

Commit

Permalink
fix(compiler): make name and namespace optional (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedconn authored and apapko committed Nov 7, 2019
1 parent e972ea7 commit 54b1529
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/@lwc/compiler/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export interface NormalizedDynamicComponentConfig {
}

export interface TransformOptions {
name: string;
namespace: string;
name?: string;
namespace?: string;
/**
* An optional directory prefix that contains the specified components
* files. Only used when the component that is the compiler's entry point.
Expand All @@ -90,6 +90,8 @@ export interface NormalizedTransformOptions extends TransformOptions {
}

export interface NormalizedCompileOptions extends CompileOptions {
name: string;
namespace: string;
outputConfig: NormalizedOutputConfig;
stylesheetConfig: NormalizedStylesheetConfig;
experimentalDynamicComponent: NormalizedDynamicComponentConfig;
Expand Down Expand Up @@ -120,12 +122,6 @@ export function validateNormalizedCompileOptions(options: NormalizedCompileOptio

export function validateOptions(options: TransformOptions) {
invariant(!isUndefined(options), CompilerValidationErrors.MISSING_OPTIONS_OBJECT, [options]);
invariant(isString(options.name), CompilerValidationErrors.INVALID_NAME_PROPERTY, [
options.name,
]);
invariant(isString(options.namespace), CompilerValidationErrors.INVALID_NAMESPACE_PROPERTY, [
options.namespace,
]);

if (!isUndefined(options.stylesheetConfig)) {
validateStylesheetConfig(options.stylesheetConfig);
Expand All @@ -139,6 +135,14 @@ export function validateOptions(options: TransformOptions) {
export function validateCompileOptions(options: CompileOptions): NormalizedCompileOptions {
validateOptions(options);

invariant(isString(options.name), CompilerValidationErrors.INVALID_NAME_PROPERTY, [
options.name,
]);

invariant(isString(options.namespace), CompilerValidationErrors.INVALID_NAMESPACE_PROPERTY, [
options.namespace,
]);

invariant(
!isUndefined(options.files) && !!Object.keys(options.files).length,
CompilerValidationErrors.INVALID_FILES_PROPERTY
Expand Down

0 comments on commit 54b1529

Please sign in to comment.