@jarwizz/create-jarshop 0.1.7 → 0.1.9

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,13 +1,28 @@
1
1
  import { vendureDashboardPlugin } from "@vendure/dashboard/vite";
2
- import { join, resolve } from "node:path";
2
+ import { LanguageCode } from "@vendure/core";
3
+ import { createRequire } from "node:module";
4
+ import { dirname, join, resolve } from "node:path";
3
5
  import { fileURLToPath, pathToFileURL } from "node:url";
4
6
  import { defineConfig } from "vite";
5
7
 
6
8
  const projectRoot = fileURLToPath(new URL(".", import.meta.url));
9
+ const requireFromRoot = createRequire(import.meta.url);
10
+
11
+ function packageDirectory(name: string): string {
12
+ return dirname(requireFromRoot.resolve(`${name}/package.json`));
13
+ }
7
14
 
8
15
  export default defineConfig({
9
16
  base: "/dashboard",
10
- build: { outDir: join(projectRoot, "dist/dashboard") },
17
+ build: {
18
+ outDir: join(projectRoot, "dist/dashboard"),
19
+ // The output directory is named by an absolute path, which is outside the
20
+ // Vite root, and Vite will not empty such a directory unless asked. Without
21
+ // this, every dashboard build layers its hashed assets on top of the last
22
+ // one: the directory grows without bound and the served chunk graph can mix
23
+ // two builds, which fails at runtime as a null React dispatcher.
24
+ emptyOutDir: true,
25
+ },
11
26
  plugins: [
12
27
  vendureDashboardPlugin({
13
28
  vendureConfigPath: pathToFileURL(
@@ -20,10 +35,33 @@ export default defineConfig({
20
35
  host: "http://localhost",
21
36
  port: Number(process.env.PORT ?? 3000),
22
37
  },
38
+ // JarShop ships its own Slovak catalogue through a patch on
39
+ // @vendure/dashboard. Vendure's own default language list has no Slovak
40
+ // in it, so the display-language dialog has to be told about it here.
41
+ i18n: {
42
+ defaultLanguage: LanguageCode.sk,
43
+ defaultLocale: "SK",
44
+ availableLanguages: [LanguageCode.sk, LanguageCode.en],
45
+ availableLocales: ["SK", "CZ", "AT", "GB", "US"],
46
+ },
23
47
  gqlOutputPath: "./src/gql",
48
+ // Dashboard extensions shipped by an installed Feature Package are found by
49
+ // scanning node_modules. The default guess is derived from wherever
50
+ // `@vendure/core` resolves, which under pnpm is a directory inside
51
+ // `node_modules/.pnpm` that holds Vendure alone — every other installed
52
+ // package is invisible from there. Point the scanner at this project's own
53
+ // `node_modules` so package-provided extensions are discovered.
54
+ pluginPackageScanner: {
55
+ nodeModulesRoot: resolve(projectRoot, "node_modules"),
56
+ },
24
57
  }),
25
58
  ],
26
59
  resolve: {
27
- alias: { "@/gql": resolve(projectRoot, "src/gql/graphql.ts") },
60
+ // Extensions and the Dashboard must share React, including JSX subpaths.
61
+ alias: {
62
+ "react-dom": packageDirectory("react-dom"),
63
+ react: packageDirectory("react"),
64
+ "@/gql": resolve(projectRoot, "src/gql/graphql.ts"),
65
+ },
28
66
  },
29
67
  });
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ // A bare `vitest run` would pick up `vite.config.mts`, which loads the
4
+ // Dashboard build plugin and the whole Vendure config just to run unit tests.
5
+ // This file keeps the Vendure-side plugin tests on a plain Node runner.
6
+ export default defineConfig({
7
+ test: {
8
+ environment: "node",
9
+ include: ["src/**/*.test.ts"],
10
+ },
11
+ });
@@ -1,3 +1,3 @@
1
1
  {
2
- "digest": "sha256:2376fe84803b036833d2afbccd72f9971964a89dd07c6592ef0c06ac07c3e40f"
2
+ "digest": "sha256:802432833a89c3edcd17a1daf767820c770d26f320dc7fbd83e9a168644935f7"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jarwizz/create-jarshop",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "private": false,
5
5
  "description": "Generate an independent JarShop Client Project.",
6
6
  "license": "MIT",