node-opcua-convert-nodeset-to-javascript 2.183.1 → 2.184.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.
Files changed (71) hide show
  1. package/dist/_dataType.d.ts +1 -0
  2. package/dist/_dataType.d.ts.map +1 -0
  3. package/dist/_dataType.js +36 -39
  4. package/dist/_dataType.js.map +1 -1
  5. package/dist/convert_namespace_to_typescript.d.ts +1 -0
  6. package/dist/convert_namespace_to_typescript.d.ts.map +1 -0
  7. package/dist/convert_namespace_to_typescript.js +72 -67
  8. package/dist/convert_namespace_to_typescript.js.map +1 -1
  9. package/dist/convert_to_typescript.d.ts +1 -0
  10. package/dist/convert_to_typescript.d.ts.map +1 -0
  11. package/dist/convert_to_typescript.js +124 -138
  12. package/dist/convert_to_typescript.js.map +1 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +3 -19
  16. package/dist/index.js.map +1 -1
  17. package/dist/main.d.ts +2 -0
  18. package/dist/main.d.ts.map +1 -0
  19. package/dist/main.js +31 -35
  20. package/dist/main.js.map +1 -1
  21. package/dist/options.d.ts +1 -0
  22. package/dist/options.d.ts.map +1 -0
  23. package/dist/options.js +1 -2
  24. package/dist/package_root.d.ts +1 -0
  25. package/dist/package_root.d.ts.map +1 -0
  26. package/dist/package_root.js +4 -10
  27. package/dist/package_root.js.map +1 -1
  28. package/dist/private/cache.d.ts +1 -0
  29. package/dist/private/cache.d.ts.map +1 -0
  30. package/dist/private/cache.js +35 -48
  31. package/dist/private/cache.js.map +1 -1
  32. package/dist/private/fs_retry.d.ts +1 -0
  33. package/dist/private/fs_retry.d.ts.map +1 -0
  34. package/dist/private/fs_retry.js +4 -11
  35. package/dist/private/fs_retry.js.map +1 -1
  36. package/dist/private/get_corresponding_data_type.d.ts +1 -0
  37. package/dist/private/get_corresponding_data_type.d.ts.map +1 -0
  38. package/dist/private/get_corresponding_data_type.js +38 -42
  39. package/dist/private/get_corresponding_data_type.js.map +1 -1
  40. package/dist/private/to_filename.d.ts +1 -0
  41. package/dist/private/to_filename.d.ts.map +1 -0
  42. package/dist/private/to_filename.js +3 -6
  43. package/dist/private/to_filename.js.map +1 -1
  44. package/dist/private/utils.d.ts +1 -0
  45. package/dist/private/utils.d.ts.map +1 -0
  46. package/dist/private/utils.js +69 -90
  47. package/dist/private/utils.js.map +1 -1
  48. package/dist/private-stuff.d.ts +1 -0
  49. package/dist/private-stuff.d.ts.map +1 -0
  50. package/dist/private-stuff.js +4 -20
  51. package/dist/private-stuff.js.map +1 -1
  52. package/dist/remove_unused.d.ts +1 -0
  53. package/dist/remove_unused.d.ts.map +1 -0
  54. package/dist/remove_unused.js +22 -28
  55. package/dist/remove_unused.js.map +1 -1
  56. package/dist/update_parent_tsconfig.d.ts +1 -0
  57. package/dist/update_parent_tsconfig.d.ts.map +1 -0
  58. package/dist/update_parent_tsconfig.js +10 -16
  59. package/dist/update_parent_tsconfig.js.map +1 -1
  60. package/dist/utils2.d.ts +1 -0
  61. package/dist/utils2.d.ts.map +1 -0
  62. package/dist/utils2.js +10 -22
  63. package/dist/utils2.js.map +1 -1
  64. package/dist/walk_through.d.ts +1 -0
  65. package/dist/walk_through.d.ts.map +1 -0
  66. package/dist/walk_through.js +19 -26
  67. package/dist/walk_through.js.map +1 -1
  68. package/package.json +19 -19
  69. package/source/convert_namespace_to_typescript.ts +15 -2
  70. package/source/main.ts +1 -0
  71. package/source/package_root.ts +1 -1
@@ -119,6 +119,8 @@ function getReleaseVersion(options: Options): string {
119
119
 
120
120
  interface Info {
121
121
  files: string[];
122
+ /** the files that emit a runtime value (an enum); every other generated file is types only */
123
+ filesWithValues: Set<string>;
122
124
  folder: string;
123
125
  module: string;
124
126
  dependencies: string[];
@@ -172,8 +174,11 @@ export async function convertNamespaceTypeToTypescript(
172
174
  fs.mkdirSync(sourceFolder);
173
175
  }
174
176
  writeFileSyncRetry(path.join(sourceFolder, `${filename}.ts`), content);
175
- infos[module] = infos[module] || { folder, dependencies: [], module, files: [] };
177
+ infos[module] = infos[module] || { folder, dependencies: [], module, files: [], filesWithValues: new Set() };
176
178
  infos[module].files.push(`${filename}.ts`);
179
+ if (type === "enum") {
180
+ infos[module].filesWithValues.add(`${filename}.ts`);
181
+ }
177
182
  infos[module].dependencies = [...new Set([...infos[module].dependencies, ...dependencies])];
178
183
  }
179
184
  };
@@ -195,7 +200,11 @@ async function _output_index_ts_file(info: Info): Promise<void> {
195
200
  if (file.match(/^enum_eration/)) {
196
201
  continue;
197
202
  }
198
- content.push(`export * from "./${file.replace(".ts", "")}.js";`);
203
+ // A types-only file compiles to an empty module, yet `export *` still loads it at
204
+ // runtime: hundreds of them per package, all paid for at startup. `export type *`
205
+ // re-exports the same types and drops the load.
206
+ const keyword = info.filesWithValues.has(file) ? "export" : "export type";
207
+ content.push(`${keyword} * from "./${file.replace(".ts", "")}.js";`);
199
208
  }
200
209
  fs.writeFileSync(index, content.join("\n"));
201
210
  // create package.json
@@ -228,6 +237,10 @@ async function _output_package_json(info: Info, options: Options): Promise<void>
228
237
  content2.push(`{`);
229
238
  content2.push(` "name": "${info.module}",`);
230
239
  content2.push(` "version": "${version}",`);
240
+ // These packages are almost entirely type declarations: what they emit is a handful of
241
+ // enums and an index that re-exports types. ESM costs them nothing and keeps them in
242
+ // step with the rest of the workspace, which is flipping package by package (FEAT-2).
243
+ content2.push(` "type": "module",`);
231
244
  content2.push(` "description": "pure nodejs OPCUA SDK - module ${info.module}",`);
232
245
  content2.push(` "main": "dist/index.js",`);
233
246
  content2.push(` "types": "dist/index.d.ts",`);
package/source/main.ts CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import fs from "node:fs";
2
3
  import os from "node:os";
3
4
  import path from "node:path";
@@ -12,7 +12,7 @@ import path from "node:path";
12
12
  * as a CLI from any directory, and cwd would then resolve somewhere else entirely.
13
13
  * A tool has to find its own files relative to itself.
14
14
  */
15
- const here = __dirname;
15
+ const here = import.meta.dirname;
16
16
 
17
17
  /** this package's own root, one level above the compiled output */
18
18
  export const packageRoot = path.join(here, "..");