@abaplint/transpiler 2.11.96 → 2.12.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.
@@ -21,9 +21,13 @@ import "./_top.mjs";\n`;
21
21
  import runtime from "@abaplint/runtime";
22
22
  globalThis.abap = new runtime.ABAP();\n`;
23
23
  }
24
- ret += `${this.buildImports(reg, useImport, options)}
25
-
26
- export async function initializeABAP() {\n`;
24
+ if (options?.setup?.filename === undefined || options?.setup?.filename === "") {
25
+ ret += `// no setup logic specified in config\n`;
26
+ }
27
+ else {
28
+ ret += `const setup = await import("${options?.setup?.filename}");\n`;
29
+ }
30
+ ret += `export async function initializeABAP() {\n`;
27
31
  ret += ` const sqlite = [];\n`;
28
32
  for (const i of dbSetup.schemas.sqlite) {
29
33
  ret += ` sqlite.push(\`${i}\`);\n`;
@@ -44,14 +48,15 @@ export async function initializeABAP() {\n`;
44
48
  ret += ` insert.push(\`${i}\`);\n`;
45
49
  }
46
50
  ret += `\n`;
47
- if (options?.extraSetup === undefined || options?.extraSetup === "") {
48
- ret += `// no setup logic specified in config\n`;
51
+ if (options?.setup?.preFunction !== undefined) {
52
+ ret += ` await setup.${options?.setup?.preFunction}(globalThis.abap, schemas, insert);\n`;
49
53
  }
50
- else {
51
- ret += ` const {setup} = await import("${options?.extraSetup}");\n` +
52
- ` await setup(globalThis.abap, schemas, insert);\n`;
54
+ ret += `}\n\n`;
55
+ ret += `await initializeABAP();\n\n`;
56
+ ret += `${this.buildImports(reg, useImport, options)}`;
57
+ if (options?.setup?.postFunction !== undefined) {
58
+ ret += `\n\nawait setup.${options?.setup?.postFunction}(globalThis.abap, schemas, insert);\n`;
53
59
  }
54
- ret += `}`;
55
60
  return ret;
56
61
  }
57
62
  buildImports(reg, useImport, options) {
@@ -47,14 +47,16 @@ export interface ITranspilerOptions {
47
47
  addCommonJS?: boolean;
48
48
  /** adds filenames as comments in the output js */
49
49
  addFilenames?: boolean;
50
- /** skip outputing constants, used for internal testing */
51
- skipConstants?: boolean;
52
50
  /** sets behavior for unknown types, either fail at compile- or run-time */
53
51
  unknownTypes?: UnknownTypesEnum;
54
52
  /** list of unit tests to skip */
55
53
  skip?: TestMethodList;
56
54
  /** extra setup script to be executed during initialization */
57
- extraSetup?: string;
55
+ setup?: {
56
+ filename: string;
57
+ preFunction?: string | undefined;
58
+ postFunction?: string | undefined;
59
+ };
58
60
  /** list of keywords to rename, if not supplied default will be used */
59
61
  keywords?: string[];
60
62
  /** populate tables, all tables are populated if undefined and they exist */
@@ -10,12 +10,11 @@ class UnitTest {
10
10
  import fs from "fs";
11
11
  import path from "path";
12
12
  import {fileURLToPath} from "url";
13
- import {initializeABAP} from "./init.mjs";
13
+ import "./init.mjs";
14
14
 
15
15
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
16
 
17
17
  async function run() {
18
- await initializeABAP();
19
18
  let lt_input = new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]});
20
19
  let ls_input = new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30)});
21
20
  let ls_result = new abap.types.Structure({list: new abap.types.Table(new abap.types.Structure({class_name: new abap.types.Character(30), testclass_name: new abap.types.Character(30), method_name: new abap.types.Character(30), expected: new abap.types.String(), actual: new abap.types.String(), status: new abap.types.String(), runtime: new abap.types.Integer(), message: new abap.types.String(), js_location: new abap.types.String(), console: new abap.types.String()}), {"withHeader":false,"type":"STANDARD","isUnique":false,"keyFields":[]}), json: new abap.types.String()});
@@ -154,7 +153,7 @@ run().then(() => {
154
153
  };
155
154
  let ret = `/* eslint-disable curly */
156
155
  /* eslint-disable max-len */
157
- import {initializeABAP} from "./init.mjs";
156
+ import "./init.mjs";
158
157
 
159
158
  function getData() {
160
159
  const ret = [];\n`;
@@ -181,7 +180,6 @@ function getData() {
181
180
  async function run() {
182
181
  const skipCritical = process.argv[2] === "--skip-critical";
183
182
  const onlyCritical = process.argv[2] === "--only-critical";
184
- await initializeABAP();
185
183
  for (const st of getData()) {
186
184
  const imported = await import(st.filename);
187
185
  const localClass = imported[st.localClass];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.11.96",
3
+ "version": "2.12.0",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,14 +29,14 @@
29
29
  "author": "abaplint",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@abaplint/core": "^2.113.218",
32
+ "@abaplint/core": "^2.113.222",
33
33
  "source-map": "^0.7.6"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/chai": "^4.3.20",
37
37
  "@types/mocha": "^10.0.10",
38
38
  "chai": "^4.5.0",
39
- "mocha": "^11.7.3",
39
+ "mocha": "^11.7.4",
40
40
  "source-map-support": "^0.5.21",
41
41
  "typescript": "^5.9.3"
42
42
  }