@gxp-dev/tools 2.0.39 → 2.0.40

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxp-dev/tools",
3
- "version": "2.0.39",
3
+ "version": "2.0.40",
4
4
  "description": "Dev tools to create platform plugins",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -211,18 +211,24 @@ export default defineConfig(({ mode }) => {
211
211
  const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
212
212
  const layoutFallbackPlugin = {
213
213
  name: "gxp-layout-fallback",
214
+ enforce: "pre",
214
215
  resolveId(source) {
215
- // Only handle @layouts/ imports
216
- if (!source.startsWith("@layouts/")) return null;
217
-
218
- const fileName = source.replace("@layouts/", "");
219
- const localFile = path.resolve(layoutsDir, fileName);
216
+ // Handle @layouts/ alias imports
217
+ if (source.startsWith("@layouts/")) {
218
+ const fileName = source.replace("@layouts/", "");
219
+ const localFile = path.resolve(layoutsDir, fileName);
220
+ if (fs.existsSync(localFile)) return null;
221
+ return `\0gxp-layout-fallback:${fileName}`;
222
+ }
220
223
 
221
- // If the file exists locally, let Vite resolve it normally
222
- if (fs.existsSync(localFile)) return null;
224
+ // Handle already-resolved absolute paths to theme-layouts/
225
+ if (source.startsWith(layoutsDir + "/")) {
226
+ if (fs.existsSync(source)) return null;
227
+ const fileName = source.replace(layoutsDir + "/", "");
228
+ return `\0gxp-layout-fallback:${fileName}`;
229
+ }
223
230
 
224
- // Return a virtual module ID for the missing file
225
- return `\0gxp-layout-fallback:${fileName}`;
231
+ return null;
226
232
  },
227
233
  load(id) {
228
234
  if (!id.startsWith("\0gxp-layout-fallback:")) return null;
@@ -150,12 +150,20 @@ export default defineConfig(({ mode }) => {
150
150
  const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
151
151
  const layoutFallbackPlugin = {
152
152
  name: "gxp-layout-fallback",
153
+ enforce: "pre",
153
154
  resolveId(source) {
154
- if (!source.startsWith("@layouts/")) return null;
155
- const fileName = source.replace("@layouts/", "");
156
- const localFile = path.resolve(layoutsDir, fileName);
157
- if (fs.existsSync(localFile)) return null;
158
- return `\0gxp-layout-fallback:${fileName}`;
155
+ if (source.startsWith("@layouts/")) {
156
+ const fileName = source.replace("@layouts/", "");
157
+ const localFile = path.resolve(layoutsDir, fileName);
158
+ if (fs.existsSync(localFile)) return null;
159
+ return `\0gxp-layout-fallback:${fileName}`;
160
+ }
161
+ if (source.startsWith(layoutsDir + "/")) {
162
+ if (fs.existsSync(source)) return null;
163
+ const fileName = source.replace(layoutsDir + "/", "");
164
+ return `\0gxp-layout-fallback:${fileName}`;
165
+ }
166
+ return null;
159
167
  },
160
168
  load(id) {
161
169
  if (!id.startsWith("\0gxp-layout-fallback:")) return null;