@vendure/dashboard 3.3.6-master-202507120238 → 3.3.6

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 (54) hide show
  1. package/dist/plugin/types.d.ts +40 -0
  2. package/dist/plugin/utils/ast-utils.d.ts +0 -5
  3. package/dist/plugin/utils/ast-utils.js +0 -67
  4. package/dist/plugin/utils/ast-utils.spec.js +1 -76
  5. package/dist/plugin/utils/compiler.d.ts +22 -0
  6. package/dist/plugin/utils/compiler.js +162 -0
  7. package/dist/plugin/utils/config-loader.d.ts +0 -120
  8. package/dist/plugin/utils/config-loader.js +1 -367
  9. package/dist/plugin/utils/logger.d.ts +3 -0
  10. package/dist/plugin/utils/logger.js +39 -0
  11. package/dist/plugin/utils/plugin-discovery.d.ts +27 -0
  12. package/dist/plugin/utils/plugin-discovery.js +343 -0
  13. package/dist/plugin/utils/tsconfig-utils.d.ts +9 -0
  14. package/dist/plugin/utils/tsconfig-utils.js +50 -0
  15. package/dist/plugin/vite-plugin-config-loader.d.ts +3 -3
  16. package/dist/plugin/vite-plugin-config-loader.js +13 -13
  17. package/dist/plugin/vite-plugin-dashboard-metadata.js +19 -2
  18. package/dist/plugin/vite-plugin-vendure-dashboard.d.ts +7 -7
  19. package/dist/plugin/vite-plugin-vendure-dashboard.js +2 -2
  20. package/package.json +134 -131
  21. package/vite/tests/barrel-exports.spec.ts +13 -4
  22. package/{dist/plugin/tests/barrel-exports/my-plugin/src/my.plugin.js → vite/tests/fixtures-npm-plugin/fake_node_modules/test-plugin/index.js} +6 -6
  23. package/vite/tests/fixtures-npm-plugin/fake_node_modules/test-plugin/package.json +8 -0
  24. package/vite/tests/fixtures-npm-plugin/package.json +6 -0
  25. package/{dist/plugin/tests/barrel-exports/vendure-config.js → vite/tests/fixtures-npm-plugin/vendure-config.ts} +5 -6
  26. package/vite/tests/fixtures-path-alias/aliased-plugin/index.ts +1 -0
  27. package/vite/tests/fixtures-path-alias/aliased-plugin/src/aliased.plugin.ts +8 -0
  28. package/vite/tests/fixtures-path-alias/package.json +6 -0
  29. package/vite/tests/fixtures-path-alias/vendure-config.ts +19 -0
  30. package/vite/tests/npm-plugin.spec.ts +46 -0
  31. package/vite/tests/path-alias.spec.ts +33 -0
  32. package/vite/tests/tsconfig.json +11 -0
  33. package/vite/types.ts +44 -0
  34. package/vite/utils/ast-utils.spec.ts +1 -80
  35. package/vite/utils/ast-utils.ts +0 -86
  36. package/vite/utils/compiler.ts +244 -0
  37. package/vite/utils/config-loader.ts +0 -555
  38. package/vite/utils/logger.ts +43 -0
  39. package/vite/utils/plugin-discovery.ts +442 -0
  40. package/vite/utils/tsconfig-utils.ts +79 -0
  41. package/vite/vite-plugin-config-loader.ts +20 -17
  42. package/vite/vite-plugin-dashboard-metadata.ts +26 -7
  43. package/vite/vite-plugin-tailwind-source.ts +2 -2
  44. package/vite/vite-plugin-vendure-dashboard.ts +9 -9
  45. package/dist/plugin/tests/barrel-exports/my-plugin/index.d.ts +0 -1
  46. package/dist/plugin/tests/barrel-exports/my-plugin/index.js +0 -17
  47. package/dist/plugin/tests/barrel-exports/my-plugin/src/my.plugin.d.ts +0 -2
  48. package/dist/plugin/tests/barrel-exports/vendure-config.d.ts +0 -2
  49. package/dist/plugin/tests/barrel-exports.spec.js +0 -14
  50. /package/dist/plugin/{tests/barrel-exports.spec.d.ts → types.js} +0 -0
  51. /package/vite/tests/{barrel-exports → fixtures-barrel-exports}/my-plugin/index.ts +0 -0
  52. /package/vite/tests/{barrel-exports → fixtures-barrel-exports}/my-plugin/src/my.plugin.ts +0 -0
  53. /package/vite/tests/{barrel-exports → fixtures-barrel-exports}/package.json +0 -0
  54. /package/vite/tests/{barrel-exports → fixtures-barrel-exports}/vendure-config.ts +0 -0
package/package.json CHANGED
@@ -1,134 +1,137 @@
1
1
  {
2
- "name": "@vendure/dashboard",
3
- "private": false,
4
- "version": "3.3.6-master-202507120238",
5
- "type": "module",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/vendure-ecommerce/vendure"
9
- },
10
- "homepage": "https://www.vendure.io",
11
- "funding": "https://github.com/sponsors/michaelbromley",
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "scripts": {
16
- "dev": "vite",
17
- "build:standalone": "vite build",
18
- "build": "tsc --project tsconfig.plugin.json",
19
- "watch": "tsc --project tsconfig.plugin.json --watch",
20
- "test": "vitest run",
21
- "lint": "eslint .",
22
- "preview": "vite preview",
23
- "generate-index": "node scripts/generate-index.js"
24
- },
25
- "module": "./src/lib/index.ts",
26
- "main": "./src/lib/index.ts",
27
- "types": "./src/lib/index.d.ts",
28
- "exports": {
29
- ".": {
30
- "types": "./src/lib/index.d.ts",
31
- "import": "./src/lib/index.ts",
32
- "require": "./src/lib/index.ts"
2
+ "name": "@vendure/dashboard",
3
+ "private": false,
4
+ "version": "3.3.6",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/vendure-ecommerce/vendure"
33
9
  },
34
- "./plugin": {
35
- "types": "./dist/plugin/index.d.ts",
36
- "import": "./dist/plugin/index.js",
37
- "require": "./dist/plugin/index.js"
38
- }
39
- },
40
- "files": [
41
- "dist",
42
- "src",
43
- "vite",
44
- "lingui.config.js",
45
- "index.html"
46
- ],
47
- "dependencies": {
48
- "@dnd-kit/core": "^6.3.1",
49
- "@dnd-kit/modifiers": "^9.0.0",
50
- "@dnd-kit/sortable": "^10.0.0",
51
- "@hookform/resolvers": "^4.1.3",
52
- "@lingui/babel-plugin-lingui-macro": "^5.2.0",
53
- "@lingui/cli": "^5.2.0",
54
- "@lingui/core": "^5.2.0",
55
- "@lingui/react": "^5.2.0",
56
- "@lingui/vite-plugin": "^5.2.0",
57
- "@radix-ui/react-accordion": "^1.2.3",
58
- "@radix-ui/react-alert-dialog": "^1.1.6",
59
- "@radix-ui/react-avatar": "^1.1.3",
60
- "@radix-ui/react-checkbox": "^1.1.4",
61
- "@radix-ui/react-collapsible": "^1.1.3",
62
- "@radix-ui/react-dialog": "^1.1.6",
63
- "@radix-ui/react-dropdown-menu": "^2.1.6",
64
- "@radix-ui/react-hover-card": "^1.1.6",
65
- "@radix-ui/react-label": "^2.1.2",
66
- "@radix-ui/react-popover": "^1.1.6",
67
- "@radix-ui/react-scroll-area": "^1.2.3",
68
- "@radix-ui/react-select": "^2.2.5",
69
- "@radix-ui/react-separator": "^1.1.2",
70
- "@radix-ui/react-slot": "^1.1.2",
71
- "@radix-ui/react-switch": "^1.1.3",
72
- "@radix-ui/react-tabs": "^1.1.3",
73
- "@radix-ui/react-tooltip": "^1.1.8",
74
- "@tailwindcss/vite": "^4.1.5",
75
- "@tanstack/eslint-plugin-query": "^5.66.1",
76
- "@tanstack/react-query": "^5.66.7",
77
- "@tanstack/react-query-devtools": "^5.68.0",
78
- "@tanstack/react-router": "^1.105.0",
79
- "@tanstack/react-table": "^8.21.2",
80
- "@tanstack/router-devtools": "^1.105.0",
81
- "@tanstack/router-plugin": "^1.105.0",
82
- "@tiptap/pm": "^2.11.5",
83
- "@tiptap/react": "^2.11.5",
84
- "@tiptap/starter-kit": "^2.11.5",
85
- "@types/react": "^19.0.10",
86
- "@types/react-dom": "^19.0.4",
87
- "@types/react-grid-layout": "^1.3.5",
88
- "@uidotdev/usehooks": "^2.4.1",
89
- "@vendure/common": "^3.3.6-master-202507120238",
90
- "@vendure/core": "^3.3.6-master-202507120238",
91
- "@vitejs/plugin-react": "^4.3.4",
92
- "awesome-graphql-client": "^2.1.0",
93
- "class-variance-authority": "^0.7.1",
94
- "clsx": "^2.1.1",
95
- "cmdk": "^1.0.0",
96
- "date-fns": "^3.6.0",
97
- "gql.tada": "^1.8.10",
98
- "graphql": "^16.10.0",
99
- "json-edit-react": "^1.23.1",
100
- "lucide-react": "^0.475.0",
101
- "motion": "^12.6.2",
102
- "next-themes": "^0.4.6",
103
- "react": "^19.0.0",
104
- "react-day-picker": "^9.6.7",
105
- "react-dom": "^19.0.0",
106
- "react-dropzone": "^14.3.8",
107
- "react-grid-layout": "^1.5.1",
108
- "react-hook-form": "^7.54.2",
109
- "recharts": "^2.15.1",
110
- "sonner": "^2.0.1",
111
- "tailwind-merge": "^3.2.0",
112
- "tailwindcss": "^4.1.5",
113
- "tailwindcss-animate": "^1.0.7",
114
- "tsconfig-paths": "^4.2.0",
115
- "tw-animate-css": "^1.2.9",
116
- "vite": "^6.3.5",
117
- "zod": "^3.24.2"
118
- },
119
- "devDependencies": {
120
- "@eslint/js": "^9.19.0",
121
- "@types/node": "^22.13.4",
122
- "eslint": "^9.19.0",
123
- "eslint-plugin-react": "^7.37.4",
124
- "eslint-plugin-react-hooks": "^5.0.0",
125
- "eslint-plugin-react-refresh": "^0.4.18",
126
- "globals": "^15.14.0",
127
- "vite-plugin-dts": "^4.5.3"
128
- },
129
- "optionalDependencies": {
130
- "lightningcss-linux-arm64-musl": "^1.29.3",
131
- "lightningcss-linux-x64-musl": "^1.29.1"
132
- },
133
- "gitHead": "8564bf5f2b06727ce0145bf616275949f07f981a"
10
+ "homepage": "https://www.vendure.io",
11
+ "funding": "https://github.com/sponsors/michaelbromley",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "dev": "vite",
17
+ "build:standalone": "vite build",
18
+ "build": "tsc --project tsconfig.plugin.json",
19
+ "watch": "tsc --project tsconfig.plugin.json --watch",
20
+ "test": "vitest run",
21
+ "lint": "eslint .",
22
+ "preview": "vite preview",
23
+ "generate-index": "node scripts/generate-index.js"
24
+ },
25
+ "module": "./src/lib/index.ts",
26
+ "main": "./src/lib/index.ts",
27
+ "types": "./src/lib/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./src/lib/index.d.ts",
31
+ "import": "./src/lib/index.ts",
32
+ "require": "./src/lib/index.ts"
33
+ },
34
+ "./plugin": {
35
+ "types": "./dist/plugin/index.d.ts",
36
+ "import": "./dist/plugin/index.js",
37
+ "require": "./dist/plugin/index.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "src",
43
+ "vite",
44
+ "lingui.config.js",
45
+ "index.html"
46
+ ],
47
+ "dependencies": {
48
+ "@dnd-kit/core": "^6.3.1",
49
+ "@dnd-kit/modifiers": "^9.0.0",
50
+ "@dnd-kit/sortable": "^10.0.0",
51
+ "@hookform/resolvers": "^4.1.3",
52
+ "@lingui/babel-plugin-lingui-macro": "^5.2.0",
53
+ "@lingui/cli": "^5.2.0",
54
+ "@lingui/core": "^5.2.0",
55
+ "@lingui/react": "^5.2.0",
56
+ "@lingui/vite-plugin": "^5.2.0",
57
+ "@radix-ui/react-accordion": "^1.2.3",
58
+ "@radix-ui/react-alert-dialog": "^1.1.6",
59
+ "@radix-ui/react-avatar": "^1.1.3",
60
+ "@radix-ui/react-checkbox": "^1.1.4",
61
+ "@radix-ui/react-collapsible": "^1.1.3",
62
+ "@radix-ui/react-dialog": "^1.1.6",
63
+ "@radix-ui/react-dropdown-menu": "^2.1.6",
64
+ "@radix-ui/react-hover-card": "^1.1.6",
65
+ "@radix-ui/react-label": "^2.1.2",
66
+ "@radix-ui/react-popover": "^1.1.6",
67
+ "@radix-ui/react-scroll-area": "^1.2.3",
68
+ "@radix-ui/react-select": "^2.2.5",
69
+ "@radix-ui/react-separator": "^1.1.2",
70
+ "@radix-ui/react-slot": "^1.1.2",
71
+ "@radix-ui/react-switch": "^1.1.3",
72
+ "@radix-ui/react-tabs": "^1.1.3",
73
+ "@radix-ui/react-tooltip": "^1.1.8",
74
+ "@tailwindcss/vite": "^4.1.5",
75
+ "@tanstack/eslint-plugin-query": "^5.66.1",
76
+ "@tanstack/react-query": "^5.66.7",
77
+ "@tanstack/react-query-devtools": "^5.68.0",
78
+ "@tanstack/react-router": "^1.105.0",
79
+ "@tanstack/react-table": "^8.21.2",
80
+ "@tanstack/router-devtools": "^1.105.0",
81
+ "@tanstack/router-plugin": "^1.105.0",
82
+ "@tiptap/pm": "^2.11.5",
83
+ "@tiptap/react": "^2.11.5",
84
+ "@tiptap/starter-kit": "^2.11.5",
85
+ "@types/react": "^19.0.10",
86
+ "@types/react-dom": "^19.0.4",
87
+ "@types/react-grid-layout": "^1.3.5",
88
+ "@uidotdev/usehooks": "^2.4.1",
89
+ "@vendure/common": "3.3.6",
90
+ "@vendure/core": "3.3.6",
91
+ "@vitejs/plugin-react": "^4.3.4",
92
+ "acorn": "^8.11.3",
93
+ "acorn-walk": "^8.3.2",
94
+ "awesome-graphql-client": "^2.1.0",
95
+ "class-variance-authority": "^0.7.1",
96
+ "clsx": "^2.1.1",
97
+ "cmdk": "^1.0.0",
98
+ "date-fns": "^3.6.0",
99
+ "fast-glob": "^3.3.2",
100
+ "gql.tada": "^1.8.10",
101
+ "graphql": "^16.10.0",
102
+ "json-edit-react": "^1.23.1",
103
+ "lucide-react": "^0.475.0",
104
+ "motion": "^12.6.2",
105
+ "next-themes": "^0.4.6",
106
+ "react": "^19.0.0",
107
+ "react-day-picker": "^9.6.7",
108
+ "react-dom": "^19.0.0",
109
+ "react-dropzone": "^14.3.8",
110
+ "react-grid-layout": "^1.5.1",
111
+ "react-hook-form": "^7.54.2",
112
+ "recharts": "^2.15.1",
113
+ "sonner": "^2.0.1",
114
+ "tailwind-merge": "^3.2.0",
115
+ "tailwindcss": "^4.1.5",
116
+ "tailwindcss-animate": "^1.0.7",
117
+ "tsconfig-paths": "^4.2.0",
118
+ "tw-animate-css": "^1.2.9",
119
+ "vite": "^6.3.5",
120
+ "zod": "^3.24.2"
121
+ },
122
+ "devDependencies": {
123
+ "@eslint/js": "^9.19.0",
124
+ "@types/node": "^22.13.4",
125
+ "eslint": "^9.19.0",
126
+ "eslint-plugin-react": "^7.37.4",
127
+ "eslint-plugin-react-hooks": "^5.0.0",
128
+ "eslint-plugin-react-refresh": "^0.4.18",
129
+ "globals": "^15.14.0",
130
+ "vite-plugin-dts": "^4.5.3"
131
+ },
132
+ "optionalDependencies": {
133
+ "lightningcss-linux-arm64-musl": "^1.29.3",
134
+ "lightningcss-linux-x64-musl": "^1.29.1"
135
+ },
136
+ "gitHead": "01a554f870d4b874b92f0d76d1602806b05f3ecc"
134
137
  }
@@ -1,20 +1,29 @@
1
+ import { rm } from 'node:fs/promises';
1
2
  import { join } from 'node:path';
2
3
  import { describe, expect, it } from 'vitest';
3
4
 
4
- import { loadVendureConfig } from '../utils/config-loader.js';
5
+ import { compile } from '../utils/compiler.js';
6
+ import { debugLogger, noopLogger } from '../utils/logger.js';
5
7
 
6
8
  describe('detecting plugins in barrel exports', () => {
7
9
  it(
8
10
  'should detect plugins in barrel exports',
9
11
  async () => {
10
- const result = await loadVendureConfig({
11
- tempDir: join(__dirname, './__temp'),
12
- vendureConfigPath: join(__dirname, 'barrel-exports', 'vendure-config.ts'),
12
+ const tempDir = join(__dirname, './__temp/barrel-exports');
13
+ await rm(tempDir, { recursive: true, force: true });
14
+ const result = await compile({
15
+ outputPath: tempDir,
16
+ vendureConfigPath: join(__dirname, 'fixtures-barrel-exports', 'vendure-config.ts'),
17
+ logger: process.env.LOG ? debugLogger : noopLogger,
13
18
  });
14
19
 
15
20
  expect(result.pluginInfo).toHaveLength(1);
16
21
  expect(result.pluginInfo[0].name).toBe('MyPlugin');
17
22
  expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
23
+ expect(result.pluginInfo[0].sourcePluginPath).toBe(
24
+ join(__dirname, 'fixtures-barrel-exports', 'my-plugin', 'src', 'my.plugin.ts'),
25
+ );
26
+ expect(result.pluginInfo[0].pluginPath).toBe(join(tempDir, 'my-plugin', 'src', 'my.plugin.js'));
18
27
  },
19
28
  { timeout: 10_000 },
20
29
  );
@@ -6,15 +6,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.MyPlugin = void 0;
9
+ exports.TestPlugin = void 0;
10
10
  const core_1 = require("@vendure/core");
11
- let MyPlugin = class MyPlugin {
11
+ let TestPlugin = class TestPlugin {
12
12
  };
13
- exports.MyPlugin = MyPlugin;
14
- exports.MyPlugin = MyPlugin = __decorate([
13
+ exports.TestPlugin = TestPlugin;
14
+ exports.TestPlugin = TestPlugin = __decorate([
15
15
  (0, core_1.VendurePlugin)({
16
16
  imports: [core_1.PluginCommonModule],
17
- providers: [],
18
17
  dashboard: './dashboard/index.tsx',
19
18
  })
20
- ], MyPlugin);
19
+ ], TestPlugin);
20
+ //# sourceMappingURL=reviews-plugin.js.map
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "test-plugin",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "build": "echo 'Building test-plugin'"
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "commonjs",
3
+ "name": "npm-plugin",
4
+ "version": "0.0.1",
5
+ "main": "index.ts"
6
+ }
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.config = void 0;
4
- const my_plugin_1 = require("./my-plugin");
5
- exports.config = {
1
+ import { VendureConfig } from '@vendure/core';
2
+ import { TestPlugin } from 'test-plugin';
3
+
4
+ export const config: VendureConfig = {
6
5
  apiOptions: {
7
6
  port: 3000,
8
7
  },
@@ -15,5 +14,5 @@ exports.config = {
15
14
  paymentOptions: {
16
15
  paymentMethodHandlers: [],
17
16
  },
18
- plugins: [my_plugin_1.MyPlugin],
17
+ plugins: [TestPlugin],
19
18
  };
@@ -0,0 +1 @@
1
+ export * from './src/aliased.plugin';
@@ -0,0 +1,8 @@
1
+ import { PluginCommonModule, VendurePlugin } from '@vendure/core';
2
+
3
+ @VendurePlugin({
4
+ imports: [PluginCommonModule],
5
+ providers: [],
6
+ dashboard: './dashboard/index.tsx',
7
+ })
8
+ export class AliasedPlugin {}
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "commonjs",
3
+ "name": "aliased-plugin",
4
+ "version": "0.0.1",
5
+ "main": "index.ts"
6
+ }
@@ -0,0 +1,19 @@
1
+ import { VendureConfig } from '@vendure/core';
2
+
3
+ import { AliasedPlugin } from './aliased-plugin';
4
+
5
+ export const config: VendureConfig = {
6
+ apiOptions: {
7
+ port: 3000,
8
+ },
9
+ authOptions: {
10
+ tokenMethod: 'bearer',
11
+ },
12
+ dbConnectionOptions: {
13
+ type: 'postgres',
14
+ },
15
+ paymentOptions: {
16
+ paymentMethodHandlers: [],
17
+ },
18
+ plugins: [AliasedPlugin],
19
+ };
@@ -0,0 +1,46 @@
1
+ import { rm } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import tsconfigPaths from 'tsconfig-paths';
4
+ import { describe, expect, it } from 'vitest';
5
+
6
+ import { compile } from '../utils/compiler.js';
7
+ import { debugLogger, noopLogger } from '../utils/logger.js';
8
+
9
+ describe('detecting plugins in npm packages', () => {
10
+ it(
11
+ 'should detect plugins in npm packages',
12
+ async () => {
13
+ const tempDir = join(__dirname, './__temp/npm-plugin');
14
+ await rm(tempDir, { recursive: true, force: true });
15
+ const fakeNodeModules = join(__dirname, 'fixtures-npm-plugin', 'fake_node_modules');
16
+
17
+ // For this test to work, we need to use tsconfigPaths to point
18
+ // the `test-plugin` package to the `fake_node_modules` directory.
19
+ // This is because the `test-plugin` package is not installed in
20
+ // the `node_modules` directory, but in the `fake_node_modules`
21
+ // directory.
22
+ tsconfigPaths.register({
23
+ baseUrl: fakeNodeModules,
24
+ paths: {
25
+ 'test-plugin': [join(fakeNodeModules, 'test-plugin')],
26
+ },
27
+ });
28
+
29
+ const result = await compile({
30
+ outputPath: tempDir,
31
+ vendureConfigPath: join(__dirname, 'fixtures-npm-plugin', 'vendure-config.ts'),
32
+ logger: process.env.LOG ? debugLogger : noopLogger,
33
+ pluginPackageScanner: {
34
+ nodeModulesRoot: fakeNodeModules,
35
+ },
36
+ });
37
+
38
+ expect(result.pluginInfo).toHaveLength(1);
39
+ expect(result.pluginInfo[0].name).toBe('TestPlugin');
40
+ expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
41
+ expect(result.pluginInfo[0].sourcePluginPath).toBeUndefined();
42
+ expect(result.pluginInfo[0].pluginPath).toBe(join(fakeNodeModules, 'test-plugin', 'index.js'));
43
+ },
44
+ { timeout: 10_000 },
45
+ );
46
+ });
@@ -0,0 +1,33 @@
1
+ import { rm } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { describe, expect, it } from 'vitest';
4
+
5
+ import { compile } from '../utils/compiler.js';
6
+ import { debugLogger, noopLogger } from '../utils/logger.js';
7
+
8
+ describe('detecting plugins using tsconfig path aliases', () => {
9
+ it(
10
+ 'should detect plugins using tsconfig path aliases',
11
+ async () => {
12
+ const tempDir = join(__dirname, './__temp/path-alias');
13
+ await rm(tempDir, { recursive: true, force: true });
14
+
15
+ const result = await compile({
16
+ outputPath: tempDir,
17
+ vendureConfigPath: join(__dirname, 'fixtures-path-alias', 'vendure-config.ts'),
18
+ logger: process.env.LOG ? debugLogger : noopLogger,
19
+ });
20
+
21
+ expect(result.pluginInfo).toHaveLength(1);
22
+ expect(result.pluginInfo[0].name).toBe('AliasedPlugin');
23
+ expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
24
+ expect(result.pluginInfo[0].sourcePluginPath).toBe(
25
+ join(__dirname, 'fixtures-path-alias', 'aliased-plugin', 'src', 'aliased.plugin.ts'),
26
+ );
27
+ expect(result.pluginInfo[0].pluginPath).toBe(
28
+ join(tempDir, 'aliased-plugin', 'src', 'aliased.plugin.js'),
29
+ );
30
+ },
31
+ { timeout: 10_000 },
32
+ );
33
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "NodeNext",
4
+ "sourceMap": true,
5
+ "jsx": "react-jsx",
6
+ "paths": {
7
+ "@plugins/*": ["./fixtures-path-alias/*"]
8
+ }
9
+ },
10
+ "exclude": ["node_modules"]
11
+ }
package/vite/types.ts ADDED
@@ -0,0 +1,44 @@
1
+ export type Logger = {
2
+ info: (message: string) => void;
3
+ warn: (message: string) => void;
4
+ debug: (message: string) => void;
5
+ error: (message: string) => void;
6
+ };
7
+
8
+ export type PluginInfo = {
9
+ name: string;
10
+ pluginPath: string;
11
+ dashboardEntryPath: string | undefined;
12
+ /** The original source path of the plugin, only set for local plugins that are compiled */
13
+ sourcePluginPath?: string;
14
+ };
15
+
16
+ export type GetCompiledConfigPathFn = (params: {
17
+ inputRootDir: string;
18
+ outputPath: string;
19
+ configFileName: string;
20
+ }) => string;
21
+
22
+ export type TransformTsConfigPathMappingsFn = (params: {
23
+ phase: 'compiling' | 'loading';
24
+ alias: string;
25
+ patterns: string[];
26
+ }) => string[];
27
+
28
+ /**
29
+ * @description
30
+ * The PathAdapter interface allows customization of how paths are handled
31
+ * when compiling the Vendure config and its imports.
32
+ */
33
+ export interface PathAdapter {
34
+ /**
35
+ * @description
36
+ * A function to determine the path to the compiled Vendure config file.
37
+ */
38
+ getCompiledConfigPath?: GetCompiledConfigPathFn;
39
+ /**
40
+ * If your project makes use of the TypeScript `paths` configuration, the compiler will
41
+ * attempt to use these paths when compiling the Vendure config and its imports.
42
+ */
43
+ transformTsConfigPathMappings?: TransformTsConfigPathMappingsFn;
44
+ }
@@ -1,86 +1,7 @@
1
1
  import ts from 'typescript';
2
2
  import { describe, expect, it } from 'vitest';
3
3
 
4
- import { findConfigExport, getPluginInfo } from './ast-utils.js';
5
-
6
- describe('getPluginInfo', () => {
7
- it('should return undefined when no plugin class is found', () => {
8
- const sourceText = `
9
- class NotAPlugin {
10
- constructor() {}
11
- }
12
- `;
13
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
14
- const result = getPluginInfo(sourceFile);
15
- expect(result).toBeUndefined();
16
- });
17
-
18
- it('should return plugin info when a valid plugin class is found', () => {
19
- const sourceText = `
20
- @VendurePlugin({
21
- imports: [],
22
- providers: []
23
- })
24
- class TestPlugin {
25
- constructor() {}
26
- }
27
- `;
28
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
29
- const result = getPluginInfo(sourceFile);
30
- expect(result).toEqual({
31
- name: 'TestPlugin',
32
- pluginPath: 'path/to',
33
- dashboardEntryPath: undefined,
34
- });
35
- });
36
-
37
- it('should handle multiple classes but only return the plugin one', () => {
38
- const sourceText = `
39
- class NotAPlugin {
40
- constructor() {}
41
- }
42
-
43
- @VendurePlugin({
44
- imports: [],
45
- providers: []
46
- })
47
- class TestPlugin {
48
- constructor() {}
49
- }
50
-
51
- class AnotherClass {
52
- constructor() {}
53
- }
54
- `;
55
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
56
- const result = getPluginInfo(sourceFile);
57
- expect(result).toEqual({
58
- name: 'TestPlugin',
59
- pluginPath: 'path/to',
60
- dashboardEntryPath: undefined,
61
- });
62
- });
63
-
64
- it('should determine the dashboard entry path when it is provided', () => {
65
- const sourceText = `
66
- @VendurePlugin({
67
- imports: [],
68
- providers: [],
69
- dashboard: './dashboard/index.tsx',
70
- })
71
- class TestPlugin {
72
- constructor() {}
73
- }
74
- `;
75
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
76
- const result = getPluginInfo(sourceFile);
77
- expect(result).toEqual({
78
- name: 'TestPlugin',
79
- pluginPath: 'path/to',
80
- dashboardEntryPath: './dashboard/index.tsx',
81
- });
82
- });
83
- });
4
+ import { findConfigExport } from './ast-utils.js';
84
5
 
85
6
  describe('findConfigExport', () => {
86
7
  it('should return undefined when no VendureConfig export is found', () => {