@cedarjs/cli 8.0.0-canary.3627 → 8.0.0-canary.3629

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 (2) hide show
  1. package/dist/lib/exec.js +28 -18
  2. package/package.json +14 -14
package/dist/lib/exec.js CHANGED
@@ -67,28 +67,38 @@ async function runScriptFunction({
67
67
  {
68
68
  find: /^web\//,
69
69
  replacement: getPaths().web.base + "/"
70
- },
71
- {
72
- find: /^src\//,
73
- replacement: "src/",
74
- customResolver: (id, importer, _options) => {
75
- const apiImportBase = importStatementPath(getPaths().api.base);
76
- const webImportBase = importStatementPath(getPaths().web.base);
77
- if (importer?.startsWith(apiImportBase)) {
78
- const apiImportSrc = importStatementPath(getPaths().api.src);
79
- const apiId = id.replace("src", apiImportSrc);
80
- return { id: resolveId(apiId) };
81
- } else if (importer?.startsWith(webImportBase)) {
82
- const webImportSrc = importStatementPath(getPaths().web.src);
83
- const webId = id.replace("src", webImportSrc);
84
- return { id: resolveId(webId) };
85
- }
86
- return null;
87
- }
88
70
  }
89
71
  ]
90
72
  },
91
73
  plugins: [
74
+ {
75
+ // When importing a file from the api directory (using api/src/... in
76
+ // the script), that file in turn might import another file using just
77
+ // src/... That's a problem for Vite when it's running a file from
78
+ // scripts/ because it doesn't know what src/ refers to. So we resolve
79
+ // it based on what file is doing the importing.
80
+ // Also, to support imports like 'src/lib/db.js' in TS projects where
81
+ // only a .ts file exists, we resolve the correct extension ourselves –
82
+ // the resolveId result is final and Vite won't try alternative
83
+ // extensions on it.
84
+ name: "cedar-resolve-src-imports",
85
+ enforce: "pre",
86
+ resolveId(id, importer) {
87
+ if (!id.startsWith("src/")) {
88
+ return null;
89
+ }
90
+ const apiImportBase = importStatementPath(getPaths().api.base);
91
+ const webImportBase = importStatementPath(getPaths().web.base);
92
+ if (importer?.startsWith(apiImportBase)) {
93
+ const apiImportSrc = importStatementPath(getPaths().api.src);
94
+ return resolveId(id.replace("src", apiImportSrc));
95
+ } else if (importer?.startsWith(webImportBase)) {
96
+ const webImportSrc = importStatementPath(getPaths().web.src);
97
+ return resolveId(id.replace("src", webImportSrc));
98
+ }
99
+ return null;
100
+ }
101
+ },
92
102
  cedarCjsCompatPlugin(),
93
103
  cedarjsResolveCedarStyleImportsPlugin(),
94
104
  cedarCellTransform(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "8.0.0-canary.3627",
3
+ "version": "8.0.0-canary.3629",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,17 +35,17 @@
35
35
  "@babel/preset-typescript": "7.29.7",
36
36
  "@babel/traverse": "7.29.12",
37
37
  "@babel/types": "7.29.11",
38
- "@cedarjs/api-server": "8.0.0-canary.3627",
39
- "@cedarjs/babel-config": "8.0.0-canary.3627",
40
- "@cedarjs/cli-helpers": "8.0.0-canary.3627",
41
- "@cedarjs/internal": "8.0.0-canary.3627",
42
- "@cedarjs/prerender": "8.0.0-canary.3627",
43
- "@cedarjs/project-config": "8.0.0-canary.3627",
44
- "@cedarjs/structure": "8.0.0-canary.3627",
45
- "@cedarjs/telemetry": "8.0.0-canary.3627",
46
- "@cedarjs/utils": "8.0.0-canary.3627",
47
- "@cedarjs/vite": "8.0.0-canary.3627",
48
- "@cedarjs/web-server": "8.0.0-canary.3627",
38
+ "@cedarjs/api-server": "8.0.0-canary.3629",
39
+ "@cedarjs/babel-config": "8.0.0-canary.3629",
40
+ "@cedarjs/cli-helpers": "8.0.0-canary.3629",
41
+ "@cedarjs/internal": "8.0.0-canary.3629",
42
+ "@cedarjs/prerender": "8.0.0-canary.3629",
43
+ "@cedarjs/project-config": "8.0.0-canary.3629",
44
+ "@cedarjs/structure": "8.0.0-canary.3629",
45
+ "@cedarjs/telemetry": "8.0.0-canary.3629",
46
+ "@cedarjs/utils": "8.0.0-canary.3629",
47
+ "@cedarjs/vite": "8.0.0-canary.3629",
48
+ "@cedarjs/web-server": "8.0.0-canary.3629",
49
49
  "@listr2/prompt-adapter-enquirer": "4.4.3",
50
50
  "@prisma/internals": "7.10.1",
51
51
  "ansis": "4.5.0",
@@ -86,7 +86,7 @@
86
86
  "yargs": "18.2.0"
87
87
  },
88
88
  "devDependencies": {
89
- "@cedarjs/framework-tools": "8.0.0-canary.3627",
89
+ "@cedarjs/framework-tools": "8.0.0-canary.3629",
90
90
  "@prisma/dmmf": "7.10.1",
91
91
  "@types/archiver": "^7.0.0",
92
92
  "memfs": "4.80.0",
@@ -95,7 +95,7 @@
95
95
  "ts-dedent": "2.3.0",
96
96
  "typescript": "5.9.3",
97
97
  "vite": "7.3.7",
98
- "vitest": "5.0.5"
98
+ "vitest": "5.1.0"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "prisma": "7.10.1"