@abaplint/transpiler-cli 2.14.32 → 2.14.33

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.
Files changed (2) hide show
  1. package/build/bundle.js +67 -4
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -125811,7 +125811,7 @@ var __importStar = (this && this.__importStar) || (function () {
125811
125811
  };
125812
125812
  })();
125813
125813
  Object.defineProperty(exports, "__esModule", ({ value: true }));
125814
- exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config = exports.importPath = exports.OutputLayout = void 0;
125814
+ exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config = exports.DDIC_MODULE = exports.importPath = exports.OutputLayout = void 0;
125815
125815
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
125816
125816
  const validation_1 = __webpack_require__(/*! ./validation */ "./node_modules/@abaplint/transpiler/build/src/validation.js");
125817
125817
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return validation_1.config; } });
@@ -125839,6 +125839,7 @@ const output_layout_1 = __webpack_require__(/*! ./output_layout */ "./node_modul
125839
125839
  var output_layout_2 = __webpack_require__(/*! ./output_layout */ "./node_modules/@abaplint/transpiler/build/src/output_layout.js");
125840
125840
  Object.defineProperty(exports, "OutputLayout", ({ enumerable: true, get: function () { return output_layout_2.OutputLayout; } }));
125841
125841
  Object.defineProperty(exports, "importPath", ({ enumerable: true, get: function () { return output_layout_2.importPath; } }));
125842
+ Object.defineProperty(exports, "DDIC_MODULE", ({ enumerable: true, get: function () { return output_layout_2.DDIC_MODULE; } }));
125842
125843
  class Transpiler {
125843
125844
  options;
125844
125845
  constructor(options) {
@@ -125926,8 +125927,46 @@ class Transpiler {
125926
125927
  for (const file of output.objects) {
125927
125928
  file.filename = layout.file(file.object, file.filename);
125928
125929
  }
125930
+ if (layout.isGrouped()) {
125931
+ output.objects = this.mergeDDIC(reg, layout, output.objects);
125932
+ }
125929
125933
  return output;
125930
125934
  }
125935
+ /** One module per output folder with all its DDIC definitions, which the initialization
125936
+ * scripts import. Each module is created for exactly the folders the initialization
125937
+ * derives from the registry, so no import can point to a missing module. */
125938
+ mergeDDIC(reg, layout, objects) {
125939
+ const modules = new Map();
125940
+ for (const obj of reg.getObjects()) {
125941
+ if (output_layout_1.DDIC_TYPES.has(obj.getType())) {
125942
+ modules.set(layout.ddicModule({ type: obj.getType(), name: obj.getName() }), []);
125943
+ }
125944
+ }
125945
+ const result = [];
125946
+ for (const file of objects) {
125947
+ if (output_layout_1.DDIC_TYPES.has(file.object.type.toUpperCase())) {
125948
+ modules.get(layout.ddicModule(file.object)).push(file);
125949
+ }
125950
+ else {
125951
+ result.push(file);
125952
+ }
125953
+ }
125954
+ for (const filename of [...modules.keys()].sort()) {
125955
+ // type factory names carry their original module name, so the definitions can be
125956
+ // concatenated without clashes; sorted, so the module does not depend on file order
125957
+ const code = modules.get(filename)
125958
+ .sort((a, b) => a.filename < b.filename ? -1 : a.filename > b.filename ? 1 : 0)
125959
+ .map(file => file.chunk.getCode()).join("\n");
125960
+ result.push({
125961
+ object: { type: "DDIC", name: filename.split("/")[0] },
125962
+ filename,
125963
+ chunk: new chunk_1.Chunk(code === "" ? "" : code + "\n"),
125964
+ requires: [],
125965
+ exports: [],
125966
+ });
125967
+ }
125968
+ return result;
125969
+ }
125931
125970
  // ///////////////////////////////
125932
125971
  validate(reg) {
125933
125972
  const issues = new validation_1.Validation(this.options).run(reg);
@@ -126076,8 +126115,13 @@ globalThis.abap = new runtime.ABAP();\n`;
126076
126115
  code: useImport === true ? `import "${specifier}";` : `await import("${specifier}");`,
126077
126116
  };
126078
126117
  };
126118
+ // grouped output merges the DDIC definitions of each folder, see DDIC_MODULE
126119
+ const ddic = new Set();
126079
126120
  for (const obj of reg.getObjects()) {
126080
- if (obj instanceof abaplint.Objects.Table
126121
+ if (this.layout.isGrouped() && output_layout_1.DDIC_TYPES.has(obj.getType())) {
126122
+ ddic.add(this.layout.ddicModule({ type: obj.getType(), name: obj.getName() }));
126123
+ }
126124
+ else if (obj instanceof abaplint.Objects.Table
126081
126125
  || obj instanceof abaplint.Objects.DataElement
126082
126126
  || obj instanceof abaplint.Objects.LockObject
126083
126127
  || obj instanceof abaplint.Objects.MessageClass
@@ -126113,7 +126157,9 @@ globalThis.abap = new runtime.ABAP();\n`;
126113
126157
  }
126114
126158
  // Folder names must not change the original module initialization order.
126115
126159
  list.sort((a, b) => a.filename < b.filename ? -1 : a.filename > b.filename ? 1 : 0);
126116
- return [...list, ...late].map(entry => entry.code).join("\n");
126160
+ // DDIC definitions only register lazy types, loading them first is always safe
126161
+ const early = [...ddic].sort().map(imp);
126162
+ return [...early, ...list, ...late].map(entry => entry.code).join("\n");
126117
126163
  }
126118
126164
  // class constructors might make early use of eg. constants from interfaces
126119
126165
  // sub classes will import() super classes and trigger a class constructor of the super
@@ -126283,8 +126329,14 @@ exports.DEFAULT_KEYWORDS = new Set([
126283
126329
  "use strict";
126284
126330
 
126285
126331
  Object.defineProperty(exports, "__esModule", ({ value: true }));
126286
- exports.OutputLayout = void 0;
126332
+ exports.OutputLayout = exports.DDIC_MODULE = exports.DDIC_TYPES = void 0;
126287
126333
  exports.importPath = importPath;
126334
+ /** Object types whose module only sets abap.DDIC[...] */
126335
+ exports.DDIC_TYPES = new Set(["DTEL", "TABL", "TTYP", "VIEW"]);
126336
+ /** Per folder module holding all its DDIC definitions. Object filenames never start
126337
+ * with an underscore, so it cannot collide with an object module. Loading tens of
126338
+ * thousands of tiny modules dominates startup, one module per folder avoids that. */
126339
+ exports.DDIC_MODULE = "_ddic.mjs";
126288
126340
  /** Browser-safe paths: generated modules use POSIX paths on every platform. */
126289
126341
  class OutputLayout {
126290
126342
  grouped;
@@ -126334,6 +126386,17 @@ class OutputLayout {
126334
126386
  const module = filename.replace(/\.abap$/i, ".mjs").toLowerCase();
126335
126387
  return folder === undefined ? module : folder + "/" + module;
126336
126388
  }
126389
+ /** With folders, the DDIC definitions of each folder share one module, see DDIC_MODULE */
126390
+ isGrouped() {
126391
+ return this.grouped;
126392
+ }
126393
+ /** The module defining this DDIC object's abap.DDIC entry */
126394
+ ddicModule(obj) {
126395
+ if (this.grouped === false) {
126396
+ throw new Error("DDIC modules are only merged in grouped output");
126397
+ }
126398
+ return this.file(obj, exports.DDIC_MODULE);
126399
+ }
126337
126400
  objectModule(obj, suffix = "") {
126338
126401
  const identifier = { name: obj.getName(), type: obj.getType() };
126339
126402
  const filename = obj.getName().toLowerCase().replace(/\//g, "#") + "." + obj.getType().toLowerCase() + suffix + ".mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.14.32",
3
+ "version": "2.14.33",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
30
  "@abaplint/core": "^2.120.105",
31
- "@abaplint/transpiler": "^2.14.32",
31
+ "@abaplint/transpiler": "^2.14.33",
32
32
  "@types/glob": "^9.0.0",
33
33
  "@types/node": "^26.6.6",
34
34
  "@types/progress": "^2.0.7",