Repository: ProjectEvergreen/greenwood (js)

Issue:
nested export conditions for import map generation not working (showing `[object Object]`)
### What happened?

Observed in our test case that we have an entry that has a resolved path that ends in `[object Object]` as is the case for the [**tslib** package](https://app.unpkg.com/tslib@2.8.1/)
https://github.com/ProjectEvergreen/greenwood/blob/v0.33.0-alpha.1/packages/cli/test/cases/develop.default/import-map.snapshot.json#L4357
```js
"tslib": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/[object Object]",
```

### Steps to reproduce

1. Start a blank project / from the init starter
1. Install tslib as a dependency
1. Start the dev server

### Environment

Latest version of Greenwood

### Additional Context

This is likely due its usage of deeply nested export conditions (the `import` case)
https://app.unpkg.com/tslib@2.8.1/files/package.json#L29
```json
{
  "exports": {
    ".": {
      "module": {
        "types": "./modules/index.d.ts",
        "default": "./tslib.es6.mjs"
      },
      "import": {
        "node": "./modules/index.js",
        "default": {
          "types": "./modules/index.d.ts",
          "default": "./tslib.es6.mjs"
        }
      },
      "default": "./tslib.js"
    },
    "./*": "./*",
    "./": "./"
  }
}
```

Pull request:
bug/issue 1508 support nested export conditions for import map generation
<!--
## Submitting a Pull Request
We love contributions and appreciate any help you can offer!
-->

## Related Issue

resolves #1508 

## Documentation 

N / A

## Summary of Changes

1. Handle nested export conditions

## TODO
1. [x] Figure out why we "lost" [**@floatingui/utils**](https://app.unpkg.com/@floating-ui/utils@0.2.9/files/package.json) along the way
    ```js
    //  before
    "@floating-ui/utils/dom": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs",
  
   // after
   "@floating-ui/utils": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs",
    ```
1. [x] Smoke test with common downstream projects - https://github.com/thescientist13/greenwood-lit-ssr
1. [x] clean up console logging

Patch:
diff --git a/packages/cli/src/lib/walker-package-ranger.js b/packages/cli/src/lib/walker-package-ranger.js
index 1a005a8e..918c8d6d 100644
--- a/packages/cli/src/lib/walker-package-ranger.js
+++ b/packages/cli/src/lib/walker-package-ranger.js
@@ -164,13 +164,38 @@ function trackExportConditions(dependency, exports, sub, condition, resolvedRoot
   if (typeof exports[sub] === "object") {
     // also check for nested conditions of conditions, default to default for now
     // https://unpkg.com/browse/@floating-ui/dom@1.6.12/package.json
-    if (sub === ".") {
+    if (typeof exports[sub][condition] === "object") {
+      for (const subCondition in exports[sub][condition]) {
+        if (SUPPORTED_EXPORT_CONDITIONS.includes(subCondition)) {
+          const segment = sub === "." ? "" : `/${sub}`;
+
+          // would this ever need to be recursive?
+          updateImportMap(
+            `${dependency}${segment}`,
+            `${exports[sub][condition][subCondition].default ?? exports[sub][condition][subCondition]}`,
+            resolvedRoot,
+          );
+
+          break;
+        }
+      }
+    } else if (sub === ".") {
+      updateImportMap(
+        dependency,
+        `${exports[sub][condition].default ?? exports[sub][condition]}`,
+        resolvedRoot,
+      );
+    } else if (SUPPORTED_EXPORT_CONDITIONS.includes(sub)) {
+      // for example, tslib
+      // https://app.unpkg.com/tslib@2.8.1/files/package.json#L37
       updateImportMap(
         dependency,
         `${exports[sub][condition].default ?? exports[sub][condition]}`,
         resolvedRoot,
       );
     } else {
+      // should this case be supported if its not a SUPPORTED_CONDITION though?
+      // cant hurt to leave it in for now I suppose...
       updateImportMap(
         `${dependency}/${sub}`,
         `${exports[sub][condition].default ?? exports[sub][condition]}`,


Test patch:
diff --git a/packages/cli/test/cases/develop.default/import-map.snapshot.json b/packages/cli/test/cases/develop.default/import-map.snapshot.json
index 508eb161..2d2c3e90 100644
--- a/packages/cli/test/cases/develop.default/import-map.snapshot.json
+++ b/packages/cli/test/cases/develop.default/import-map.snapshot.json
@@ -1,6 +1,6 @@
 {
-  "@beforesemicolon/markup": "/~/Users/owenbuckley/Workspace/github/greenwood-markup-todo-app/node_modules/@beforesemicolon/markup/dist/esm/index.js",
-  "@beforesemicolon/html-parser": "/~/Users/owenbuckley/Workspace/github/greenwood-markup-todo-app/node_modules/@beforesemicolon/html-parser/dist/esm/index.js",
+  "@beforesemicolon/markup": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@beforesemicolon/markup/dist/esm/index.js",
+  "@beforesemicolon/html-parser": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@beforesemicolon/html-parser/dist/esm/index.js",
   "@shoelace-style/shoelace": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@shoelace-style/shoelace/dist/shoelace.js",
   "@shoelace-style/shoelace/dist/custom-elements.json": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@shoelace-style/shoelace/dist/custom-elements.json",
   "@shoelace-style/shoelace/dist/shoelace.js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/@shoelace-style/shoelace/dist/shoelace.js",
@@ -4157,7 +4157,7 @@
   "resolve-id-refs": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/resolve-id-refs/index.js",
   "sass/types": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/sass/types/index.d.ts",
   "sass/node": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/sass/sass.node.mjs",
-  "sass/default": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/sass/sass.default.js",
+  "sass": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/sass/sass.default.js",
   "chokidar": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/chokidar/index.js",
   "anymatch": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/anymatch/index.js",
   "normalize-path": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/normalize-path/index.js",
@@ -4354,17 +4354,17 @@
   "signal-utils/set": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/signal-utils/dist/set.ts.js",
   "signal-utils/weak-map": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/signal-utils/dist/weak-map.ts.js",
   "signal-utils/weak-set": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/signal-utils/dist/weak-set.ts.js",
-  "tslib": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/[object Object]",
-  "tslib/CopyrightNotice.txt": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/CopyrightNotice.txt",
-  "tslib/LICENSE.txt": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/LICENSE.txt",
-  "tslib/README.md": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/README.md",
-  "tslib/SECURITY.md": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/SECURITY.md",
-  "tslib/package.json": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/package.json",
-  "tslib/tslib.d.ts": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/tslib.d.ts",
-  "tslib/tslib.es6.html": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/tslib.es6.html",
-  "tslib/tslib.es6.js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/tslib.es6.js",
-  "tslib/tslib.es6.mjs": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/tslib.es6.mjs",
-  "tslib/tslib.html": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/tslib.html",
-  "tslib/tslib.js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/tslib.js",
-  "tslib/": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/node_modules/tslib/"
+  "tslib": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.es6.mjs",
+  "tslib/CopyrightNotice.txt": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/CopyrightNotice.txt",
+  "tslib/LICENSE.txt": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/LICENSE.txt",
+  "tslib/README.md": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/README.md",
+  "tslib/SECURITY.md": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/SECURITY.md",
+  "tslib/package.json": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/package.json",
+  "tslib/tslib.d.ts": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.d.ts",
+  "tslib/tslib.es6.html": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.es6.html",
+  "tslib/tslib.es6.js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.es6.js",
+  "tslib/tslib.es6.mjs": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.es6.mjs",
+  "tslib/tslib.html": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.html",
+  "tslib/tslib.js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/tslib.js",
+  "tslib/": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/tslib/"
 }