jsii 5.8.23-dev.0 → 5.8.23-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -204,6 +204,10 @@ export declare class Assembler implements Emitter {
204
204
  * not output position
205
205
  */
206
206
  private validateTypesAgainstPositions;
207
+ /**
208
+ * Make sure that no 2 submodules are emitting into the same target namespaces
209
+ */
210
+ private validateSubmoduleConfigs;
207
211
  }
208
212
  export interface AssemblerOptions {
209
213
  /**
package/lib/assembler.js CHANGED
@@ -140,6 +140,7 @@ class Assembler {
140
140
  }
141
141
  this.callDeferredsInOrder();
142
142
  this.validateTypesAgainstPositions();
143
+ this.validateSubmoduleConfigs();
143
144
  // Skip emitting if any diagnostic message is an error
144
145
  if (this._diagnostics.find((diag) => diag.category === ts.DiagnosticCategory.Error) != null) {
145
146
  LOG.debug('Skipping emit due to errors.');
@@ -171,6 +172,7 @@ class Assembler {
171
172
  bundled: this.projectInfo.bundleDependencies,
172
173
  types: Object.fromEntries(this._types),
173
174
  submodules: noEmptyDict(toSubmoduleDeclarations(this.mySubmodules())),
175
+ // Force this into shape
174
176
  targets: this.projectInfo.targets,
175
177
  metadata: {
176
178
  ...this.projectInfo.metadata,
@@ -554,8 +556,16 @@ class Assembler {
554
556
  };
555
557
  }
556
558
  function loadSubmoduleTargetConfig(submoduleMain) {
557
- const jsiirc = path.resolve(submoduleMain, '..', '.jsiirc.json');
558
- if (!fs.existsSync(jsiirc)) {
559
+ const dirname = path.dirname(submoduleMain);
560
+ const basenameWithoutExtension = path.basename(submoduleMain).replace(/\.ts$/, '');
561
+ let jsiirc;
562
+ if (basenameWithoutExtension === 'index') {
563
+ jsiirc = path.resolve(submoduleMain, '..', '.jsiirc.json');
564
+ }
565
+ else {
566
+ jsiirc = path.resolve(dirname, `.${basenameWithoutExtension}.jsiirc.json`);
567
+ }
568
+ if (!jsiirc || !fs.existsSync(jsiirc)) {
559
569
  return undefined;
560
570
  }
561
571
  const data = JSON.parse(fs.readFileSync(jsiirc, 'utf-8'));
@@ -2028,6 +2038,48 @@ class Assembler {
2028
2038
  });
2029
2039
  }
2030
2040
  }
2041
+ /**
2042
+ * Make sure that no 2 submodules are emitting into the same target namespaces
2043
+ */
2044
+ validateSubmoduleConfigs() {
2045
+ const self = this;
2046
+ const dotNetnamespaces = {};
2047
+ const javaPackages = {};
2048
+ const pythonModules = {};
2049
+ const goPackages = {};
2050
+ for (const submodule of this._submodules.values()) {
2051
+ const targets = submodule.targets;
2052
+ if (targets?.dotnet?.namespace) {
2053
+ accumList(dotNetnamespaces, targets.dotnet.namespace, submodule.fqn);
2054
+ }
2055
+ if (targets?.java?.package) {
2056
+ accumList(javaPackages, targets.java.package, submodule.fqn);
2057
+ }
2058
+ if (targets?.python?.module) {
2059
+ accumList(pythonModules, targets.python.module, submodule.fqn);
2060
+ }
2061
+ if (targets?.go?.packageName) {
2062
+ accumList(goPackages, targets.go.packageName, submodule.fqn);
2063
+ }
2064
+ }
2065
+ maybeError('dotnet', dotNetnamespaces);
2066
+ maybeError('java', javaPackages);
2067
+ maybeError('python', pythonModules);
2068
+ maybeError('go', goPackages);
2069
+ function accumList(set, key, value) {
2070
+ if (!set[key]) {
2071
+ set[key] = [];
2072
+ }
2073
+ set[key].push(value);
2074
+ }
2075
+ function maybeError(language, set) {
2076
+ for (const [namespace, modules] of Object.entries(set)) {
2077
+ if (modules.length > 1) {
2078
+ self._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_4010_SUBMODULE_NAMESPACE_CONFLICT.create(undefined, language, namespace, modules));
2079
+ }
2080
+ }
2081
+ }
2082
+ }
2031
2083
  }
2032
2084
  exports.Assembler = Assembler;
2033
2085
  function _fingerprint(assembly) {