jsii 5.9.12 → 5.9.14-dev.0

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.');
@@ -555,8 +556,16 @@ class Assembler {
555
556
  };
556
557
  }
557
558
  function loadSubmoduleTargetConfig(submoduleMain) {
558
- const jsiirc = path.resolve(submoduleMain, '..', '.jsiirc.json');
559
- 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)) {
560
569
  return undefined;
561
570
  }
562
571
  const data = JSON.parse(fs.readFileSync(jsiirc, 'utf-8'));
@@ -2029,6 +2038,48 @@ class Assembler {
2029
2038
  });
2030
2039
  }
2031
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
+ }
2032
2083
  }
2033
2084
  exports.Assembler = Assembler;
2034
2085
  function _fingerprint(assembly) {