dumi 2.4.12-beta.1 → 2.4.13

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.
@@ -94,21 +94,27 @@ function emitDemo(opts, ret) {
94
94
  const { demos } = ret.meta;
95
95
  const shareDepsMap = {};
96
96
  const demoDepsMap = {};
97
+ const relativeDepsMap = {};
97
98
  demos == null ? void 0 : demos.forEach((demo) => {
98
- var _a;
99
+ var _a, _b;
99
100
  if ("resolveMap" in demo && "asset" in demo) {
100
101
  const entryFileName = Object.keys(demo.asset.dependencies)[0];
101
102
  demoDepsMap[_a = demo.id] ?? (demoDepsMap[_a] = {});
103
+ relativeDepsMap[_b = demo.id] ?? (relativeDepsMap[_b] = {});
102
104
  Object.keys(demo.resolveMap).forEach((key, index) => {
103
105
  const specifier = `${demo.id.replace(/[^\w\d]/g, "_")}_deps_${index}`;
104
106
  if (key !== entryFileName) {
105
- const normalizedKey = isRelativePath(key) ? (0, import_plugin_utils.winPath)(demo.resolveMap[key]) : key;
107
+ const isRelative = isRelativePath(key);
108
+ const normalizedKey = isRelative ? (0, import_plugin_utils.winPath)(demo.resolveMap[key]) : key;
106
109
  if (!shareDepsMap[normalizedKey]) {
107
110
  demoDepsMap[demo.id][normalizedKey] = specifier;
108
111
  shareDepsMap[normalizedKey] = specifier;
109
112
  } else {
110
113
  demoDepsMap[demo.id][normalizedKey] = shareDepsMap[normalizedKey];
111
114
  }
115
+ if (isRelative) {
116
+ relativeDepsMap[demo.id][key] = `{{{${shareDepsMap[normalizedKey] || specifier}}}}`;
117
+ }
112
118
  }
113
119
  });
114
120
  }
@@ -171,7 +177,7 @@ export const demos = {
171
177
  ...acc,
172
178
  ...{ [key]: `{{{${specifier}}}}` }
173
179
  }),
174
- {}
180
+ relativeDepsMap[this.id]
175
181
  );
176
182
  return JSON.stringify(context, null, 2).replace(/"{{{|}}}"/g, "");
177
183
  },
@@ -105,11 +105,8 @@ export async function getFullDemos() {
105
105
  // expand context for omit ext
106
106
  expandDemoContext(demo.context);
107
107
  });
108
-
109
- return {
110
- ...total,
111
- ...demos,
112
- };
108
+ Object.assign(total, demos);
109
+ return total;
113
110
  }, {}),
114
111
  );
115
112
  }
@@ -184,10 +181,10 @@ export async function getFullRoutesMeta(): Promise<Record<string, IRouteMeta>> {
184
181
  })),
185
182
  ).then((ret) =>
186
183
  ret.reduce(
187
- (total, { id, meta }) => ({
188
- ...total,
189
- [id]: meta,
190
- }),
184
+ (total, { id, meta }) => {
185
+ total[id] = meta;
186
+ return total;
187
+ },
191
188
  {},
192
189
  ),
193
190
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.4.12-beta.1",
3
+ "version": "2.4.13",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",