-
Notifications
You must be signed in to change notification settings - Fork 35
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
chore(headless, atomic-react)!: add exports field in package.json #4376
Conversation
Pull Request ReportPR Title✅ Title follows the conventional commit spec. Live demo linksBundle Size
SSR Progress
Detailed logssearch : buildInteractiveResultsearch : buildInteractiveInstantResult search : buildInteractiveRecentResult search : buildInteractiveCitation search : buildGeneratedAnswer recommendation : missing SSR support product-recommendation : missing SSR support product-listing : missing SSR support case-assist : missing SSR support insight : missing SSR support commerce : missing SSR support |
e810501
to
21eb5cb
Compare
- module: import_typescript.default.ModuleKind.ESNext, | ||
- moduleResolution: import_typescript.default.ModuleResolutionKind.NodeJs, | ||
+ module: import_typescript.default.ModuleKind.ES2022, | ||
+ moduleResolution: import_typescript.default.ModuleResolutionKind.Bundler, |
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.
The new "exports" field in package.json defining the different entry points needs moduleResolution
in tsconfig.ts
to be either Bundler/Node16/NodeNext
. From now on, every user of Headless will have to use one of these three for their typescript compiler to understand where to look for subpackages. More info on the "exports" field .
There is a problem with Stencil however. Inside of their compiler, they use an old version of moduleResolution
that cant find the subpackages with the "exports" field. This is a known bug and will be fixed in v5.
This patch above fixes this by changing the default value used by the stencil compiler.
1235c25
to
71fc98c
Compare
e25bfdf
to
fecfa1c
Compare
async function main() { | ||
const buildPromises = Object.entries(USE_CASES).flatMap( | ||
([useCaseName, entryPoint]) => [ | ||
browserEsm(entryPoint, useCaseName), | ||
esm(entryPoint, useCaseName), | ||
cjs(entryPoint, useCaseName), | ||
iife(entryPoint, useCaseName), | ||
] | ||
); | ||
await Promise.all(buildPromises); | ||
} | ||
|
||
main(); |
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.
I ended up having problems with the build process of Atomic-React. It was using simply tsc compilation to compile for these 2 use case (esm, cjs) and rollup for iife. Since it was just using tsc compilation and since we now have to put either Bundler/node16/nodeNext as moduleResolution. We couldnt use tsc to compile into cjs and iife. I had to change the build process to esbuild. All the changes in the /atomic-react folder are related to this.
I also added a browserEsm output for <script type="module"> cases. All the new output looks like this.
import { | ||
QuerySetSection, | ||
QuerySuggestionSection, | ||
} from '@coveo/headless/dist/definitions/state/state-sections'; |
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.
This shows how you cant import from anything other than the "exports" defined paths in the package json. Only from @coveo/headless , @coveo/headless/commerce, and so on...
… need new build for atomic-react
…to renovate/stencil
- `);for(const p of n){const u=p.tagName,l=T(u),$=`${l}Element`,b=`${l}CustomEvent`;e.addImportDeclaration({moduleSpecifier:`${s}/${i}/${u}.js`,namedImports:[{name:l,alias:$},{name:"defineCustomElement",alias:`define${l}`}]});const F=(p.events||[]).filter(o=>o.internal===!1),y=[];for(const o of F)if(Object.keys(o.complexType.references).length>0){for(const _ of Object.keys(o.complexType.references))o.complexType.references[_].location==="global"||e.addImportDeclaration({moduleSpecifier:s,namedImports:[{name:_,isTypeOnly:!0}]});e.addImportDeclaration({moduleSpecifier:s,namedImports:[{name:b,isTypeOnly:!0}]}),y.push({originalName:o.name,name:j(o.name),type:`EventName<${b}<${o.complexType.original}>>`})}else y.push({originalName:o.name,name:j(o.name),type:`EventName<CustomEvent<${o.complexType.original}>>`});const E=`${l}Events`;e.addTypeAlias({name:E,type:y.length>0?`{ ${y.map(o=>`${o.name}: ${o.type}`).join(`, | ||
+ `);for(const p of n){const u=p.tagName,l=T(u),$=`${l}Element`,b=`${l}CustomEvent`;e.addImportDeclaration({moduleSpecifier:`${s}/${i}/${u}.js`,namedImports:[{name:l,alias:$},{name:"defineCustomElement",alias:`define${l}`}]});const F=(p.events||[]).filter(o=>o.internal===!1),y=[];for(const o of F)if(Object.keys(o.complexType.references).length>0){for(const _ of Object.keys(o.complexType.references))o.complexType.references[_].location==="global"||e.addImportDeclaration({moduleSpecifier:s,namedImports:[{name:_,isTypeOnly:!0}]});e.addImportDeclaration({moduleSpecifier:s,namedImports:[{name:b,isTypeOnly:!0}]}),y.push({originalName:o.name,name:j(o.name),type:`EventName<${b}<${o.complexType.original}>>`})}else y.push({originalName:o.name,name:j(o.name),type:`EventName<CustomEvent<${o.complexType.original}>>`});const E=`${l}Events`;e.addTypeAlias({name:E,type:y.length>0?`{ ${y.map(o=>`'${o.name}': ${o.type}`).join(`, |
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.
https://coveord.atlassian.net/browse/KIT-2541
This PR adds the "exports" field for @coveo/headless and @coveo/atomic-react. More details here - > https://github.com/coveo/ui-kit/pull/4376/files#r1746030192
this PR also updates stencil, angular-output-target and react-output-target