Skip to content

Commit

Permalink
make bueno external for headless
Browse files Browse the repository at this point in the history
  • Loading branch information
fpbrault committed Sep 19, 2024
1 parent b62f3c7 commit 5e0941d
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 9 deletions.
34 changes: 33 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@
"wait-on": "7.2.0"
},
"peerDependencies": {
"@coveo/headless": "3.0.0"
"@coveo/headless": "2.80.0",
"@coveo/bueno": "0.46.1"
},
"license": "Apache-2.0",
"engines": {
Expand Down
8 changes: 6 additions & 2 deletions packages/atomic/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ import {inlineSvg} from 'stencil-inline-svg';
import tailwind from 'tailwindcss';
import tailwindNesting from 'tailwindcss/nesting';
import headlessJson from '../../packages/headless/package.json';
import buenoJson from '../../packages/headless/package.json';
import {generateAngularModuleDefinition as angularModule} from './stencil-plugin/atomic-angular-module';

const isProduction = process.env.BUILD === 'production';
const isCDN = process.env.DEPLOYMENT_ENVIRONMENT === 'CDN';

let headlessVersion: string = '';
let buenoVersion: string = '';

if (isCDN) {
console.log('Building for CDN');
headlessVersion = 'v' + headlessJson.version;
buenoVersion = 'v' + buenoJson.version;
}

const packageMappings: {[key: string]: {devWatch: string; cdn: string}} = {
Expand Down Expand Up @@ -68,10 +72,10 @@ const packageMappings: {[key: string]: {devWatch: string; cdn: string}} = {
devWatch: path.resolve(__dirname, './src/external-builds/headless.esm.js'),
cdn: `/headless/${headlessVersion}/headless.esm.js`,
},
/* '@coveo/bueno': {
'@coveo/bueno': {
devWatch: path.resolve(__dirname, './src/external-builds/bueno.esm.js'),
cdn: `/bueno/${buenoVersion}/bueno.esm.js`,
}, */
},
};

function generateAliasEntries() {
Expand Down
30 changes: 29 additions & 1 deletion packages/bueno/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ function browserEsm() {
});
}

function browserEsmForAtomicDevelopment() {
const buildAtomic = build({
...base,
platform: 'browser',
outfile: '../atomic/src/external-builds/bueno.esm.js',
format: 'esm',
watch: devMode,
minify: false,
});

const buildHeadless = build({
...base,
platform: 'browser',
outfile: '../headless/src/external-builds/bueno.esm.js',
format: 'esm',
watch: devMode,
minify: false,
});

return Promise.all([buildAtomic, buildHeadless]);
}

function browserUmd() {
return build({
...base,
Expand All @@ -58,7 +80,13 @@ function browserUmd() {
}

async function main() {
await Promise.all([nodeCjs(), nodeEsm(), browserEsm(), browserUmd()]);
await Promise.all([
nodeCjs(),
nodeEsm(),
browserEsm(),
browserUmd(),
browserEsmForAtomicDevelopment(),
]);
}

main();
12 changes: 12 additions & 0 deletions packages/bueno/project.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
{
"name": "bueno",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"namedInputs": {
"negativeBuildOutputs": [
"!{projectRoot}/dist",
"!{workspaceRoot}/packages/atomic/src/external-builds",
"!{workspaceRoot}/packages/headless/src/external-builds"
]
},
"targets": {
"release:phase1": {},
"cached:build": {
"executor": "nx:run-commands",
"outputs": [
"{projectRoot}/dist",
"{workspaceRoot}/packages/atomic/src/external-builds",
"{workspaceRoot}/packages/headless/src/external-builds"
],
"options": {
"commands": ["npm run build:bundles", "npm run build:definitions"],
"parallel": true,
Expand Down
4 changes: 3 additions & 1 deletion packages/headless/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docs/js
temp/
doc-parser/build
doc-parser/build

src/external-builds
19 changes: 16 additions & 3 deletions packages/headless/esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import alias from 'esbuild-plugin-alias';
import {aliasPath} from 'esbuild-plugin-alias-path';
import {umdWrapper} from 'esbuild-plugin-umd-wrapper';
import {readFileSync, promises, writeFileSync} from 'node:fs';
import {readFileSync, writeFileSync} from 'node:fs';
import {createRequire} from 'node:module';
import {dirname, resolve} from 'node:path';
import path, {dirname, resolve} from 'node:path';
import {build} from '../../scripts/esbuild/build.mjs';
import {apacheLicense} from '../../scripts/license/apache.mjs';

const require = createRequire(import.meta.url);
const devMode = process.argv[2] === 'dev';

const __dirname = dirname(new URL(import.meta.url).pathname);

const useCaseEntries = {
search: 'src/index.ts',
recommendation: 'src/recommendation.index.ts',
Expand Down Expand Up @@ -85,6 +88,16 @@ const browserEsmForAtomicDevelopment = Object.entries(useCaseEntries).map(
format: 'esm',
watch: devMode,
minify: false,
plugins: [
aliasPath({
alias: {
'@coveo/bueno': path.resolve(
__dirname,
'./src/external-builds/bueno.esm.js'
),
},
}),
],
},
outDir
);
Expand Down Expand Up @@ -192,7 +205,7 @@ async function buildBrowserConfig(options, outDir) {
minify: true,
sourcemap: true,
metafile: true,
external: ['crypto'],
external: ['crypto', '@coveo/bueno'],
...options,
plugins: [
alias({
Expand Down
1 change: 1 addition & 0 deletions packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"@microsoft/api-extractor": "7.47.3",
"@microsoft/api-extractor-model": "7.29.3",
"@microsoft/tsdoc": "0.15.0",
"esbuild-plugin-alias-path": "2.0.2",
"eslint-plugin-canonical": "4.18.0",
"execa": "8.0.1",
"install": "0.13.0",
Expand Down

0 comments on commit 5e0941d

Please sign in to comment.