@onexapis/cli 1.1.32 → 1.1.36

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/dist/cli.js CHANGED
@@ -187,6 +187,10 @@ async function scanImportsFromPackage(sourceDir, packageName) {
187
187
  `(?:import|export)\\s+(?:type\\s+)?\\{([^}]+)\\}\\s+from\\s+["']${escapedPkg}(/[\\w./-]+)?["']`,
188
188
  "g"
189
189
  );
190
+ const namespaceImportRegex = new RegExp(
191
+ `import\\s+\\*\\s+as\\s+\\w+\\s+from\\s+["']${escapedPkg}(/[\\w./-]+)?["']`,
192
+ "g"
193
+ );
190
194
  const sourceFiles = await glob.glob("**/*.{ts,tsx}", {
191
195
  cwd: sourceDir,
192
196
  ignore: ["node_modules/**", "dist/**"]
@@ -194,6 +198,11 @@ async function scanImportsFromPackage(sourceDir, packageName) {
194
198
  for (const file of sourceFiles) {
195
199
  try {
196
200
  const content = await fs7__default.default.readFile(path8__default.default.join(sourceDir, file), "utf-8");
201
+ for (const match of content.matchAll(namespaceImportRegex)) {
202
+ const subpath = match[1] ? match[1].slice(1) : "";
203
+ if (!result[subpath]) result[subpath] = /* @__PURE__ */ new Set();
204
+ result[subpath].add("*");
205
+ }
197
206
  for (const match of content.matchAll(importRegex)) {
198
207
  const subpath = match[2] ? match[2].slice(1) : "";
199
208
  if (!result[subpath]) result[subpath] = /* @__PURE__ */ new Set();
@@ -234,8 +243,10 @@ function createCoreGlobalPlugin(themePath) {
234
243
  const moduleAccess = subpath ? `['${subpath}']` : "";
235
244
  let namedExports = [];
236
245
  const cacheKey = subpath || "__root__";
237
- if (exportsBySubpath[cacheKey]) {
238
- namedExports = exportsBySubpath[cacheKey];
246
+ const cached = exportsBySubpath[cacheKey];
247
+ const needsAllExports = cached?.includes("*");
248
+ if (cached && cached.length > 0 && !needsAllExports) {
249
+ namedExports = [...new Set(cached)];
239
250
  } else {
240
251
  const distFileName = subpath ? `${subpath}.mjs` : "index.mjs";
241
252
  let distPath = await resolveNodeModulesFile(
@@ -259,6 +270,11 @@ function createCoreGlobalPlugin(themePath) {
259
270
  }).filter((n) => n.length > 0);
260
271
  namedExports.push(...names);
261
272
  }
273
+ if (cached && cached.length > 0) {
274
+ for (const n of cached) {
275
+ if (n !== "*") namedExports.push(n);
276
+ }
277
+ }
262
278
  namedExports = [...new Set(namedExports)];
263
279
  } catch {
264
280
  }