@likec4/config 1.39.1 → 1.39.3

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.
@@ -1,6 +1,7 @@
1
1
  import { invariant } from "@likec4/core";
2
- import { bundleNRequire } from "bundle-n-require";
2
+ import { bundleRequire } from "bundle-require";
3
3
  import * as fs from "node:fs/promises";
4
+ import { dirname } from "node:path";
4
5
  import { defineConfig } from "../define-config.mjs";
5
6
  import { isLikeC4JsonConfig, isLikeC4NonJsonConfig } from "../filenames.mjs";
6
7
  import { logger } from "../logger.mjs";
@@ -18,8 +19,33 @@ export async function loadConfig(filepath) {
18
19
  }
19
20
  invariant(isLikeC4NonJsonConfig(filepath.fsPath), `Invalid config file: ${filepath.fsPath}`);
20
21
  try {
21
- const { mod } = await bundleNRequire(filepath.fsPath, {
22
- interopDefault: true
22
+ const cwd = dirname(filepath.fsPath);
23
+ const { mod } = await bundleRequire({
24
+ filepath: filepath.fsPath,
25
+ cwd,
26
+ esbuildOptions: {
27
+ resolveExtensions: [".mjs", ".js", ".ts", ".mts"],
28
+ plugins: [{
29
+ name: "likec4-config",
30
+ setup(build) {
31
+ build.onResolve({ filter: /^@?likec4\/config$/ }, (args) => ({
32
+ path: args.path,
33
+ namespace: "likec4-config"
34
+ }));
35
+ build.onLoad({ filter: /.*/, namespace: "likec4-config" }, (args) => {
36
+ return {
37
+ contents: `
38
+ function mockDefineConfig(x) { return x }
39
+ export {
40
+ mockDefineConfig as defineConfig,
41
+ mockDefineConfig as defineGenerators,
42
+ }`,
43
+ loader: "js"
44
+ };
45
+ });
46
+ }
47
+ }]
48
+ }
23
49
  });
24
50
  return defineConfig(mod?.default ?? mod);
25
51
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/config",
3
- "version": "1.39.1",
3
+ "version": "1.39.3",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -54,24 +54,33 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "bundle-n-require": "^1.1.2",
57
+ "bundle-require": "^5.1.0",
58
58
  "defu": "^6.1.4",
59
59
  "json5": "^2.2.3",
60
- "remeda": "^2.23.1",
61
- "type-fest": "^4.41.0",
60
+ "zod": "^4.0.17"
61
+ },
62
+ "peerDependencies": {
63
+ "esbuild": ">=0.25",
62
64
  "vscode-uri": "3.1.0",
63
- "zod": "^4.0.17",
64
- "@likec4/core": "1.39.1",
65
- "@likec4/log": "1.39.1"
65
+ "@likec4/core": "1.39.3",
66
+ "@likec4/log": "1.39.3"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "@likec4/core": {
70
+ "optional": true
71
+ },
72
+ "vscode-uri": {
73
+ "optional": true
74
+ }
66
75
  },
67
76
  "devDependencies": {
68
77
  "@types/node": "~20.19.11",
69
- "tsx": "4.20.3",
78
+ "tsx": "4.20.5",
70
79
  "turbo": "2.5.6",
71
80
  "typescript": "5.9.2",
72
81
  "unbuild": "3.5.0",
73
82
  "vitest": "3.2.4",
74
- "@likec4/tsconfig": "1.39.1"
83
+ "@likec4/tsconfig": "1.39.3"
75
84
  },
76
85
  "scripts": {
77
86
  "generate": "tsx scripts/generate.mts",
@@ -80,5 +89,7 @@
80
89
  "lint:package": "pnpx publint ./package.tgz",
81
90
  "clean": "pnpm rimraf dist lib",
82
91
  "pack": "pnpm pack"
83
- }
92
+ },
93
+ "types": "./dist/index.d.ts",
94
+ "module": "./dist/index.mjs"
84
95
  }
@@ -1,6 +1,7 @@
1
1
  import { invariant } from '@likec4/core'
2
- import { bundleNRequire } from 'bundle-n-require'
2
+ import { bundleRequire } from 'bundle-require'
3
3
  import * as fs from 'node:fs/promises'
4
+ import { dirname } from 'node:path'
4
5
  import type { URI } from 'vscode-uri'
5
6
  import { defineConfig } from '../define-config'
6
7
  import { isLikeC4JsonConfig, isLikeC4NonJsonConfig } from '../filenames'
@@ -25,8 +26,39 @@ export async function loadConfig(filepath: URI): Promise<LikeC4ProjectConfig> {
25
26
 
26
27
  invariant(isLikeC4NonJsonConfig(filepath.fsPath), `Invalid config file: ${filepath.fsPath}`)
27
28
  try {
28
- const { mod } = await bundleNRequire(filepath.fsPath, {
29
- interopDefault: true,
29
+ const cwd = dirname(filepath.fsPath)
30
+ const { mod } = await bundleRequire({
31
+ filepath: filepath.fsPath,
32
+ cwd,
33
+ esbuildOptions: {
34
+ resolveExtensions: ['.mjs', '.js', '.ts', '.mts'],
35
+ plugins: [{
36
+ name: 'likec4-config',
37
+ setup(build) {
38
+ /**
39
+ * Intercept @likec4/config imports
40
+ */
41
+ build.onResolve({ filter: /^@?likec4\/config$/ }, (args) => ({
42
+ path: args.path,
43
+ namespace: 'likec4-config',
44
+ }))
45
+ /**
46
+ * Mock implementation, this allows to skip redundant bundling @likec4/config
47
+ */
48
+ build.onLoad({ filter: /.*/, namespace: 'likec4-config' }, (args) => {
49
+ return {
50
+ contents: `
51
+ function mockDefineConfig(x) { return x }
52
+ export {
53
+ mockDefineConfig as defineConfig,
54
+ mockDefineConfig as defineGenerators,
55
+ }`,
56
+ loader: 'js',
57
+ }
58
+ })
59
+ },
60
+ }],
61
+ },
30
62
  })
31
63
  return defineConfig(mod?.default ?? mod)
32
64
  } catch (err) {