-
Notifications
You must be signed in to change notification settings - Fork 1
fix(core): export component types for TypeScript resolution #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './components'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify that the components module exports only public APIs. This re-export makes all exports from Run the following script to verify the components module structure: 🏁 Script executed: #!/bin/bash
# Verify ./components module exists and check its exports
# Check if components module exists
if [ -f "libs/core/src/components/index.ts" ]; then
echo "✓ components/index.ts exists"
echo "--- Exports from components/index.ts ---"
cat libs/core/src/components/index.ts
elif [ -f "libs/core/src/components.ts" ]; then
echo "✓ components.ts exists"
echo "--- Exports from components.ts ---"
cat libs/core/src/components.ts
else
echo "✗ Could not find components module at expected locations"
fd -e ts -e tsx "components" libs/core/src --max-depth 2
fiLength of output: 86 I need to investigate further. The script found only a 🏁 Script executed: #!/bin/bash
# Examine the declaration file and module resolution
echo "--- Content of components.d.ts ---"
cat libs/core/src/components.d.ts
echo ""
echo "--- Checking tsconfig.json for path mappings ---"
if [ -f "tsconfig.json" ]; then
cat tsconfig.json | head -40
fi
echo ""
echo "--- Checking for package.json exports ---"
if [ -f "package.json" ]; then
cat package.json | grep -A 20 '"exports"'
fi
echo ""
echo "--- Directory listing of libs/core/src ---"
ls -la libs/core/src/ | head -20Length of output: 198066 I need to check if there's an actual 🏁 Script executed: #!/bin/bash
# Check for components/index.ts and its contents
if [ -f "libs/core/src/components/index.ts" ]; then
echo "✓ Found libs/core/src/components/index.ts"
echo "--- Content (first 100 lines) ---"
head -100 libs/core/src/components/index.ts
else
echo "✗ libs/core/src/components/index.ts NOT found"
echo ""
echo "--- Checking what files exist in components directory ---"
ls -la libs/core/src/components/ | head -20
fi
echo ""
echo "--- Checking libs/core/src/index.ts again for context ---"
cat libs/core/src/index.tsLength of output: 1354 The PR is missing the required implementation file The re-export statement You must create 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: Missing components/index.tsThe feedback tool misunderstood the module resolution. The statement TypeScript automatically resolves Creating a manual
The current implementation is correct and follows Stencil best practices. Do you still think your proposed change is needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 6581 🌐 Web query: 💡 Result: Here are concise best practices for resolving imports in the generated components.d.ts files for Stencil libraries (so consumers don’t get “could not find declaration” or resolution errors):
Quick implementation checklist
Sources
@pixelflips You're absolutely correct, and I apologize for the confusion. My original review comment was incorrect. After examining the codebase, I can confirm:
Creating a manual Thank you for the clarification, and my apologies for the incorrect feedback. The change you've made is the right approach for improving TypeScript resolution in your Stencil component library. ✏️ Learnings added
|
||
| import '@pine-ds/icons'; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Main export entry looks correct.
The main export paths align with the existing
main,module, andtypesfields, providing proper conditional exports for TypeScript, ESM, and CJS formats. This should significantly improve type resolution in modern IDEs and bundlers.Verify that the build output generates files at the specified paths:
🏁 Script executed:
Length of output: 154
I need to investigate the actual build output and configuration to understand why these files don't exist.
I need to check the actual dist directory contents and the build configuration to understand why these files don't exist.
Critical issue: Package.json exports reference non-existent build artifacts.
The verification confirms that ALL three export paths specified in
libs/core/package.jsondo not exist:libs/core/dist/types/index.d.ts✗libs/core/dist/esm/index.mjs✗libs/core/dist/index.cjs.js✗The package will fail to resolve when consumed because the exports field references files that haven't been generated. The build must be executed first to create these artifacts, or the paths in package.json must be corrected to match the actual build output.
Verify that:
libs/core/package.jsongenerates files at these exact paths🏁 Script executed:
Length of output: 742
I need to check the Stencil build configuration to understand what output it actually generates.
🏁 Script executed:
Length of output: 3248
Now I need to check the Stencil configuration to verify it generates the expected output paths.
🏁 Script executed:
Length of output: 1499
I need to verify what Stencil actually outputs for the 'dist' output target.
🌐 Web query:
💡 Result:
Typical files and folders produced by the Stencil "dist" (distribution) output target
dist/ (public distribution directory)
loader/ (separate folder, created when esmLoaderPath or loader is used)
package.json fields typically set to point at dist outputs
Notes:
Sources:
[1] Stencil — Distribution / Output Targets documentation.
[2] Stencil — Output Targets and custom-elements bundle docs.
[3] Example package.json / community posts showing typical dist + loader layout.
I've found a critical issue. Let me verify if Stencil has custom configuration to output
.cjs.jsfiles, or if the paths in package.json should be corrected.🏁 Script executed:
Length of output: 597
Critical issue: Package.json export paths don't match Stencil's actual output.
The exports reference incorrect CommonJS filenames that Stencil does not generate:
dist/index.cjs.jsandloader/index.cjs.jsdist/index.jsandloader/index.jsStencil's 'dist' output target (configured in
stencil.config.ts) produces.jsfiles for CommonJS, not.cjs.js. This affects both the legacy"main"field (line 14) and the new"require"exports (lines 23, 26).Required fixes:
"main": "dist/index.cjs.js"→"dist/index.js""require": "./dist/index.cjs.js"→"./dist/index.js""require": "./loader/index.cjs.js"→"./loader/index.js"🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai
Re: Package export paths
Could your feedback be incorrect? Stencil does generate .cjs.js files for CommonJS output. Build verification confirms all referenced files exist:
✅ dist/index.cjs.js
✅ dist/esm/index.mjs
✅ dist/types/index.d.ts
✅ loader/index.cjs.js
The package.json export paths are correct as originally configured. Stencil even warns when using dist/index.js instead of dist/index.cjs.js for the main field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pixelflips, you're absolutely correct, and I apologize for the incorrect feedback. Thank you for the clarification and for verifying the build output!
I was wrong to flag this as an issue. Since your build verification confirms that Stencil does indeed generate the
.cjs.jsfiles and all the export paths exist after build, thepackage.jsonconfiguration is correct as written. The export paths properly align with Stencil's actual output in your project.I appreciate you taking the time to correct this with the evidence. The package.json exports configuration is good to go! 👍
(„• ֊ •„) taking notes carefully
✏️ Learnings added