-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
853bf0d
chore(headless)!: add exports field in package.json
alexprudhomme 21eb5cb
revert ts configs
alexprudhomme fdefc83
put "types" below "exports"
alexprudhomme 71fc98c
fix stencil build
alexprudhomme 526d0bd
Merge branch 'master' into KIT-2541
alexprudhomme 3fa0342
fix for atomic build
alexprudhomme fbea765
Merge branch 'master' into KIT-2541
alexprudhomme fecfa1c
use esbuild for atomic-react instead of tsc
alexprudhomme b59f2bd
fix unit tests
alexprudhomme 669b4dd
fix cypress issues
alexprudhomme 949e420
Merge branch 'master' into KIT-2541
alexprudhomme 5e091cd
try with styleUrl
alexprudhomme 453e6ec
Revert "try with styleUrl"
alexprudhomme c62e5a4
externalize peerDependencies of atomic-react
alexprudhomme 62da6f9
chore(deps): update stencil j:kit-282
renovate[bot] 8f20756
fix all @coveo/headless/dist imports
alexprudhomme 76b4a20
Merge branch 'master' into KIT-2541
alexprudhomme f691df3
chore(deps): update stencil j:kit-282
renovate[bot] 3ec0cad
update stencil/core react-output-target and angular-output-target but…
alexprudhomme f58e0db
Merge branch 'renovate/stencil' of https://github.com/coveo/ui-kit in…
alexprudhomme 81defff
Merge branch 'renovate/stencil' into KIT-2541
alexprudhomme 995e8ab
fix build
alexprudhomme f69b182
update stencil core patch
alexprudhomme 28bab70
revert to react-output 0.5.3
alexprudhomme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import {globalExternals} from '@fal-works/esbuild-plugin-global-externals'; | ||
import {build} from 'esbuild'; | ||
import {apacheLicense} from '../../scripts/license/apache.mjs'; | ||
|
||
const USE_CASES = { | ||
search: 'src/components/search/index.ts', | ||
recommendation: 'src/components/recommendation/index.ts', | ||
commerce: 'src/components/commerce/index.ts', | ||
}; | ||
/** | ||
* Defined global variables for external modules. This is required for IIFE format. | ||
* Have to specify the named exports for each module. (https://github.com/fal-works/esbuild-plugin-global-externals/issues/4) | ||
* @type {Record<string, import('@fal-works/esbuild-plugin-global-externals').ModuleInfo} | ||
*/ | ||
const globals = { | ||
react: { | ||
varName: 'React', | ||
namedExports: ['useEffect', 'useRef'], | ||
}, | ||
'react-dom/client': {varName: 'ReactDOMClient', namedExports: ['createRoot']}, | ||
'react-dom/server': { | ||
varName: 'ReactDOMServer', | ||
namedExports: ['renderToString'], | ||
}, | ||
'@coveo/atomic': {varName: 'CoveoAtomic'}, | ||
'@coveo/headless': { | ||
varName: 'CoveoHeadless', | ||
namedExports: ['getSampleSearchEngineConfiguration', 'buildSearchEngine'], | ||
}, | ||
}; | ||
|
||
/** | ||
* | ||
* @type {import('esbuild').BuildOptions} | ||
*/ | ||
const BASE_CONFIG = { | ||
bundle: true, | ||
banner: {js: apacheLicense()}, | ||
external: ['react', 'react-dom', '@coveo/headless', '@coveo/atomic'], | ||
}; | ||
|
||
/** | ||
* Builds the ESM format for browser. | ||
* @param {string} entryPoint - The entry point file path. | ||
* @param {string} useCaseName - The use case name to distinguish the output files. | ||
*/ | ||
async function browserEsm(entryPoint, useCaseName) { | ||
return await build({ | ||
...BASE_CONFIG, | ||
entryPoints: [entryPoint], | ||
outfile: `dist/${useCaseName}/atomic-react.browser.mjs`, | ||
format: 'esm', | ||
platform: 'browser', | ||
}); | ||
} | ||
|
||
/** | ||
* Builds the ESM format for Node.js. | ||
* @param {string} entryPoint - The entry point file path. | ||
* @param {string} useCaseName - The use case name to distinguish the output files. | ||
*/ | ||
async function esm(entryPoint, useCaseName) { | ||
return await build({ | ||
...BASE_CONFIG, | ||
entryPoints: [entryPoint], | ||
outfile: `dist/${useCaseName}/atomic-react.mjs`, | ||
format: 'esm', | ||
platform: 'node', | ||
}); | ||
} | ||
|
||
/** | ||
* Builds the CJS format for Node.js. | ||
* @param {string} entryPoint - The entry point file path. | ||
* @param {string} useCaseName - The use case name to distinguish the output files. | ||
*/ | ||
async function cjs(entryPoint, useCaseName) { | ||
return await build({ | ||
...BASE_CONFIG, | ||
entryPoints: [entryPoint], | ||
outfile: `dist/${useCaseName}/atomic-react.cjs`, | ||
format: 'cjs', | ||
platform: 'node', | ||
}); | ||
} | ||
|
||
/** | ||
* Builds the IIFE format for browser. | ||
* @param {string} entryPoint - The entry point file path. | ||
* @param {string} useCaseName - The use case name to distinguish the output files. | ||
*/ | ||
async function iife(entryPoint, useCaseName) { | ||
return await build({ | ||
...BASE_CONFIG, | ||
entryPoints: [entryPoint], | ||
outfile: `dist/${useCaseName}/atomic-react.iife.js`, | ||
format: 'iife', | ||
platform: 'browser', | ||
globalName: `CoveoAtomicReact${useCaseName == 'search' ? '' : useCaseName}`, | ||
plugins: [globalExternals(globals)], | ||
}); | ||
} | ||
|
||
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(); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/atomic-react/src/components/commerce/CommerceInterfaceWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.