Skip to content

Instantly share code, notes, and snippets.

@arackaf
Created July 30, 2018 00:41
Show Gist options
  • Save arackaf/9ae28ca76b3aaacab263a09bf06f7614 to your computer and use it in GitHub Desktop.
Save arackaf/9ae28ca76b3aaacab263a09bf06f7614 to your computer and use it in GitHub Desktop.
const glob = require("glob"),
fs = require("fs");
/** Translate a glob expression to bundle arithmetic expression. Use this in your bundle definitions if you want to include based on glob expressions. */
function jsGlob(globText) {
let regex = new RegExp("^../dist/");
return (
" ( " +
glob
.sync("../dist/" + globText)
.filter(entry => !fs.statSync(entry).isDirectory())
.map(entry => entry.replace(regex, ""))
.join(" + ") +
" ) "
);
}
//region VARIOUS GROUPS - Can define here to be used in the actual build definitions below.
var notesContentExc =
"notes/components/composer/composer - notes/components/content/composeWidget - notes/components/content/editWidget - bundles/shared/* - knockout-tinymce";
const labelsUtilities = ["claims/shared/claimsLabelsComponent", "contacts/shared/contactsLabelsComponent"];
const contactsDetailsSeparateHtml1 = [
"contacts/details/view/additional.htm!text",
"contacts/details/view/basics.htm!text",
"contacts/details/view/payors.htm!text"
];
const fileUploadExclusion = [
"shared/fileupload/**/*.js",
"shared/fileUpload/**/*.js",
"shared/fileupload/**/*.htm!text",
"shared/fileUpload/**/*.htm!text",
"shared/fileUpload"
].join(" - ");
const appUtilComponents = ["bootstrap", "util"].map(dir => `[app/components/${dir}/**/*.js]`).join(" + ");
const allSeparateToExclude = " ( " + contactsDetailsSeparateHtml1.join(" + ") + " ) ";
let sharedFoldersBuild1 = ["customFilter", "export", "filterList", "filters"],
sharedBuild1 = sharedFoldersBuild1.map(folder => `${jsGlob(`shared/${folder}/**/*.js`)} + shared/${folder}/**/*.htm!text`).join(" + ");
const commonToAny = (...items) => {
let result = [];
for (let i = 0; i < items.length; i++) {
for (let j = i + 1; j < items.length; j++) {
result.push(` ( ${items[i]} & ${items[j]} ) `);
}
}
return result.join(" + ");
};
const billingPaymentsPayments = " ( billingmanager/payments/payments/payments + billingmanager/payments/payments/paymentsStore ) ",
billingPaymentsBatches = " ( billingmanager/payments/batches/batches + billingmanager/payments/batches/batchesStore ) ",
billingPaymentsTransactions = " ( billingmanager/payments/transactions/transactions + billingmanager/payments/transactions/transactionsStore ) ",
billingPaymentsImport = " ( billingmanager/payments/importbatch/importbatch + billingmanager/payments/importbatch/importbatchStore ) ",
billingPaymentsCommon = commonToAny(billingPaymentsPayments, billingPaymentsBatches, billingPaymentsTransactions, billingPaymentsImport);
let accruedSections = ["monthovermonth", "receivablesbyage", "summary"];
//endregion
//region Exported Bundle Definitions
module.exports = {
/** Label-related utils that we include in core but exclude from other bundles. */
labelsUtilities,
assetDependencies: [{ what: "mobx + mobx-react + prop-types + create-react-class - [react-dom] - [reactRaw]", saveTo: "mobx-and-react-core" }],
/** Dependency bundles for the main/core framework bundles. */
crDependencyBundles: [
{ what: "react-motion + react-height + react-collapse", saveTo: "react-collapse-bundle" },
{ what: "[app/util/fileupload/fileupload.js]", saveTo: "legacy-upload" },
{ what: "ag-grid", saveTo: "ag-grid-utility" },
{
what: `[app/components/core] + [app/components/forms/**/*.js] + [app/components/layout/**/*.js] + [app/components/navigation/**/*.js]`,
saveTo: "app-components-core-forms-layout"
},
{ what: `[app/components/charting/**/*.js]`, saveTo: "app-components-charting" },
{ what: "[app/util/agGrid/**/*.js]", saveTo: "app-ag-grid" },
{ what: "[app/util/searchVm] + [app/util/defaultSearchMap] + [app/components/searchVm/**/*.js]", saveTo: "app-searchvm" },
{
what: `[app/util/*.js] + [app/util/bootstrapHelpers/**/*.js] + ${appUtilComponents} + [app/stores/loadingSubmoduleStore] - @app-searchvm`,
saveTo: "app-util"
},
{ what: "[app/components/select/**/*.js]", saveTo: "select2-components" },
{
what: "[app/util/labels/**/*.js] + [app/stores/labels/**/*.js] + [app/components/labels/**/*.js] + [app/models/labels/**/*.js]",
saveTo: "app-labels-build"
},
{ what: "[app/stores/filterLists/**/*.js] + [app/components/filterLists/**/*.js]", saveTo: "app-filter-lists-build" },
{ what: "[app/stores/chat/**/*.js] + [app/components/chat/**/*.js] + [app/util/chat/**/*.js]", saveTo: "app-chat-build" },
{
what:
"app/util/filters/**/*.js + app/stores/filters/**/*.js + app/components/filters/**/*.js + app/models/filters/**/*.js - @app-util - react-collapse",
saveTo: "app-filters-build"
},
{
what:
jsGlob("widgets/**/*.js") +
" + widgets/**/*.htm!text + framework/globalUtils/agGridHelpers + framework/globalUtils/nestedLabelsComponent + framework/globalUtils/singleLabelsSelect2Component + framework/globalUtils/labelUtilities - framework/koMapper/mapper + " +
labelsUtilities.join(" + ") +
" - app/util/**/*.js",
saveTo: "global-helpers-and-all-widgets"
},
{
what: "framework/koMapper/mapper + " + jsGlob("framework/koMapper/**/*.js") + " - framework/globalUtils/labelUtilities",
saveTo: "ko-mapper-bundle"
},
{
what: "[app/components/framework/listSubmodule/**/*.js] + [app/stores/framework/listSubmodule/**/*.js]",
saveTo: "framework-components-listSubmodule"
},
{ what: "[app/router/**/*.js]", saveTo: "react-routing" },
{ what: "[app/components/videoplaying/**/*.js] + [app/stores/videoplaying/**/*.js]", saveTo: "react-video-playing-bundle" },
{ what: "([app/components/upload/**/*.js] + [app/stores/upload/**/*.js]) - @react-video-playing-bundle", saveTo: "react-upload-bundle" },
{ what: "[app/components/contactcard/contactCard] + [app/stores/contactcard/contactCardStore]", saveTo: "contactcard-bundle" },
{ what: "[app/components/export/exportModal] + [app/stores/export/export]", saveTo: "export-bundle" }
],
/** Dependency bundles for modules, usually good to extract things here that may be used across modules. */
moduleDependencyBundles: [
{ what: "tasks/list/responsiveComponents/desktopList", saveTo: "tasks-list-desktop" },
{ what: "tasks/list/responsiveComponents/mobileList", saveTo: "tasks-list-mobile" },
{ what: jsGlob("tasks/list/models/**/*.js"), saveTo: "tasks-list-models" },
{ what: "resources/list/responsiveComponents/desktopList", saveTo: "resources-list-desktop" },
{ what: "resources/list/responsiveComponents/mobileList", saveTo: "resources-list-mobile" },
{ what: "contacts/list/responsiveComponents/desktopList", saveTo: "contacts-list-desktop" },
{ what: "contacts/list/responsiveComponents/mobileList", saveTo: "contacts-list-mobile" },
{ what: "payroll/assets/responsiveComponents/desktopList", saveTo: "payroll-assets-desktop" },
{ what: "payroll/assets/responsiveComponents/mobileList", saveTo: "payroll-assets-mobile" },
{ what: "scheduling/list/responsiveComponents/desktopList", saveTo: "scheduling-list-desktop" },
{ what: "scheduling/list/responsiveComponents/mobileList", saveTo: "scheduling-list-mobile" },
{ what: "bundles/list/responsiveComponents/desktopList", saveTo: "bundles-list-desktop" },
{ what: "bundles/list/responsiveComponents/mobileList", saveTo: "bundles-list-mobile" },
{
// INSURANCE VERIFICATION SHARED
what:
jsGlob("contacts/details/view/payors/insurance/models/**/*") +
" + " +
jsGlob("contacts/details/view/payors/insurance/components/**/*") +
" + " +
jsGlob("contacts/details/view/payors/insurance/services/**/*") +
" + contacts/details/view/payors/insurance/utils",
saveTo: "insurance-verification-shared"
},
{ what: "(bundles/group/group & bundles/session/session) + " + jsGlob("bundles/session/sessionViews/**/*.js"), saveTo: "shared-bundles-util-1" },
{ what: "[bundles/bundle/vmPrint]", saveTo: "vmPrint" },
{ what: "contacts/utilities/metadataFieldEditor + contacts/utilities/metadataFieldStore.js", saveTo: "contacts-metadata-helpers" },
{ what: jsGlob("contacts/details/widgets/**/*.js") + " - @insurance-verification-shared", saveTo: "contacts-details-widgets" },
{
what:
jsGlob("contacts/details/modules/**/*.js") +
" + " +
"contacts/details/modules/**/*.htm!text - contacts/details/modules/DashboardWidgetUtilities - @tasks-list-models - messaging/list/list - resources/details/details - @insurance-verification-shared",
saveTo: "contacts-details-modules"
},
{ what: jsGlob("contacts/details/view/profile/**/*.js") + " - widgets/*", saveTo: "all-profile-bundles" },
{ what: "contacts/details/view/profile/**/*.htm!text", saveTo: "all-profile-bundles-html" },
{ what: `messaging/list/list & ( ${jsGlob("contacts/details/modules/**/*.js")} ) - messaging/list/listStore`, saveTo: "messaging-shared" },
{ what: `messaging/list/listStore`, saveTo: "messaging-list-store" },
{ what: `resources/details/details & ( ${jsGlob("contacts/details/modules/**/*.js")} )`, saveTo: "resources-contacts-modules-shared" },
{
what: jsGlob("contacts/details/view/health/**/*.js") + " + contacts/details/view/health/baseUtilities - widgets/*",
saveTo: "all-health-bundles"
},
{ what: "contacts/details/view/health/**/*.htm!text", saveTo: "all-health-bundles-html" },
{
what:
jsGlob("contacts/details/view/**/*.js") +
" - contacts/details/view/health/**/*.js - contacts/details/view/profile/**/*.js - @contacts-details-widgets - @insurance-verification-shared",
saveTo: "contacts-details-view"
},
{
what: `contacts/details/view/**/*.htm!text - contacts/details/view/health/**/*.htm!text - contacts/details/view/profile/**/*.htm!text - ${allSeparateToExclude}`,
saveTo: "contacts-details-view-html1"
},
{ what: contactsDetailsSeparateHtml1.join(" + "), saveTo: "contacts-details-view-html2" },
{ what: billingPaymentsCommon, saveTo: "billing-payments-common" },
{ what: billingPaymentsPayments + " - @billing-payments-common", saveTo: "billing-payments-payments" },
{ what: billingPaymentsBatches + " - @billing-payments-common", saveTo: "billing-payments-batches" },
{ what: billingPaymentsTransactions + " - @billing-payments-common", saveTo: "billing-payments-transactions" },
{ what: billingPaymentsImport + " - @billing-payments-common", saveTo: "billing-payments-importBatches" },
{
what: jsGlob("bundles/assessment/templates/**/*.js") + " + " + "bundles/assessment/templates/**/*.htm!text",
saveTo: "bundlesAssessmentTemplates"
},
{ what: "billingmanager/payments/batches/desktopList", saveTo: "payments-batches-desktoplist" },
{
what: "billingmanager/payments/payments/desktopList - @billing-payments-common - @billing-payments-transactions",
saveTo: "payments-payments-desktoplist"
},
{ what: "billingmanager/receivables/desktopList", saveTo: "receivables-desktoplist" },
{ what: "billingmanager/receivables/mobileList", saveTo: "receivables-mobilelist" },
{
what:
"( " + accruedSections.map(folder => jsGlob(`billingmanager/accrued/${folder}/**/*.js`)).join(" + ") + " ) - billingmanager/accrued/accrued",
saveTo: `billingmanager-accrued-helpers`
},
{
what: "billingmanager/clientdefaults/**/*.htm!text - billingmanager/clientdefaults/clientdefaults.htm!text",
saveTo: "billingmanager-clientdefaults-htm"
},
{ what: "billingmanager/driverates/**/*.htm!text - billingmanager/driverates/driverates.htm!text", saveTo: "billingmanager-driverates-htm" },
{ what: "billingmanager/servicecodes/bulk/**/*.htm!text", saveTo: "billingmanager-servicecodes-bulk-htm" },
{ what: "billingmanager/servicecodes/item/**/*.htm!text", saveTo: "billingmanager-servicecodes-item-htm" },
{ what: "billingmanager/servicecodes/list/**/*.htm!text", saveTo: "billingmanager-servicecodes-list-htm" },
{ what: "bundles/bundle/edit/**/*.htm!text", saveTo: "bundles-edit-htm" },
{ what: "bundles/bundle/home/**/*.htm!text", saveTo: "bundles-home-htm" },
{ what: "bundles/bundle/item/**/item-data*.htm!text", saveTo: "bundles-item-data-htm" },
{ what: "bundles/bundle/item/**/*.htm!text - bundles/bundle/item/**/item-data*.htm!text", saveTo: "bundles-item-non-data-htm" },
{ what: "bundles/goaldashboard/views/**/*.htm!text", saveTo: "bundles-goaldashboard-htm" },
{ what: "bundles/session/sessionViews/**/*.htm!text", saveTo: "bundles-session-sessionViews-htm" },
{ what: "bundles/session/view/**/*.htm!text", saveTo: "bundles-session-view-htm" },
{ what: "bundles/vbmapp/**/*.htm!text - bundles/vbmapp/vbmapp.htm!text", saveTo: "bundles-vbmapp-htm" },
{ what: "claims/editor/**/*.htm!text - claims/editor/editor.htm!text", saveTo: "claims-editor-view-htm" }
],
/** Defines the modules and their submodules, used to generate modulesToBuild (in the expandCompleteModules step) for the actual build. When adding/modifying CR modules/submodules, be sure to verify here that your stuff will be bundled correctly. */
completeModules: {
billingmanager: {
payments: "billingmanager/payments/payments - @billing-payments-common"
},
bundles: {
bundle: "bundles/bundle/bundle - bundles/bundle/vmPrint - bundles/report/* + bundles/bundle/data + bundles/bundle/modalBase",
group: "bundles/group/group - @shared-bundles-util-1",
session: "bundles/session/session - @shared-bundles-util-1",
vbmapp: "bundles/vbmapp/vbmapp",
vbmappscore: "bundles/vbmappscore/vbmappscore + bundles/vbmappscore/scoring/**/*.htm!text "
},
claims: {},
contacts: {
root: "contacts/contacts - contacts/forms/* - forms/*",
details: "contacts/details/details + contacts/details/*.htm!text - contacts/details/details.htm!text - @insurance-verification-shared",
list: "contacts/list/list - contacts-details-widgets - contacts-details-view",
forms: "contacts/forms/forms - contacts/forms/shared",
utilities: "contacts/utilities/utilities - contacts/forms/forms",
list: "contacts/list/list - @insurance-verification-shared"
},
forms: {
root: "forms/forms - contacts/forms/shared"
},
messaging: {
list: "messaging/list/list - @messaging-shared - @messaging-list-store"
},
payroll: {
__bundleWithRoot:
jsGlob("payroll/helper/**/*.js") +
" + payroll/helper/**/*.htm!text + " +
jsGlob("payroll/shared/**/*.js") +
" + payroll/benefitsummary/benefitSummary + payroll/benefitsummary/benefitSummaryStore + payroll/benefitplans/benefitPlanQueries + payroll/ptoPolicyQueries",
excludeSubModules: ["benefitsummary"]
},
permissions: {
__bundleWithRoot:
jsGlob("permissions/models/**/*.js") + " + " + jsGlob("permissions/services/**/*.js") + " + " + jsGlob("permissions/components/**/*.js")
},
register: {},
resources: {
details: "resources/details/details - @resources-contacts-modules-shared",
templatesreport: "resources/templatesreport/list"
},
scheduling: {},
tasks: {
root: "tasks/tasks",
list: "tasks/list/list - @tasks-list-models",
excludeSubModules: ["sandbox", "sandbox2"]
}
},
/** Do not put anything here. It is generated from the 'completeModules' definition. */
modulesToBuild: [],
/** Bundles that are required/used by the 'utilsToBuild' below. */
utilityDependencyBundles: [
{ what: jsGlob("notes/components/content/client**/*.js") + " - " + notesContentExc, saveTo: "notes-client-health-content" },
{ what: "notes/components/content/client**/*.htm!text", saveTo: "notes-client-health-content-html" },
{ what: jsGlob("notes/components/content/learn**/*.js") + " - " + notesContentExc, saveTo: "notes-learn-content" },
{ what: "notes/components/content/learn**/*.htm!text", saveTo: "notes-learn-content-html" },
{
what: jsGlob("notes/components/content/**/*.js") + " - @notes-client-health-content - @notes-learn-content - " + notesContentExc,
saveTo: "notes-other-content"
},
{
what: "notes/components/content/**/*.htm!text - @notes-client-health-content-html - @notes-learn-content-html",
saveTo: "notes-other-content-html"
},
{
what:
"notes/notes + notes/notes.htm!text + notes/notes.css!css + notes/components/composer/composer + notes/components/composer/composer.htm!text + notes/components/composer/selector + notes/components/composer/selector.htm!text + notes/components/composer/loader + notes/components/content/composeWidget + notes/components/content/editWidget - widgets/* - contacts/details/view/health/* - knockout-tinymce",
saveTo: "notes-misc-bundle-1"
},
{
what:
"[notes/composer/composer] + notes/composer/composer.htm!text + [notes/components/templates/editor] + notes/components/templates/editor.htm!text + [notes/components/templates/menu] + notes/components/templates/selector + notes/components/templates/selector.htm!text + notes/components/composer/standalone + notes/components/composer/standalone.htm!text - notes/components/composer/composer - widgets/* - contacts/details/view/health/*",
saveTo: "notes-misc-bundle-2"
},
{ what: sharedBuild1, saveTo: "shared-build1" },
{ what: "contacts/shared/contactLabelsStore", saveTo: "contacts-labels-store" },
{ what: "tasks/shared/taskLabelsStore", saveTo: "tasks-labels-store" },
{ what: jsGlob("billingmanager/shared/**/*.js") + " + billingmanager/shared/**/*.htm!text", saveTo: "billingmanager-shared" },
{
what: jsGlob("contacts/shared/**/*.js") + " + contacts/shared/**/*.htm!text - @contacts-labels-store - @tasks-labels-store",
saveTo: "contacts-shared"
},
{ what: jsGlob("forms/shared/**/*.js") + " + forms/shared/**/*.htm!text", saveTo: "forms-shared" },
{ what: jsGlob("resources/shared/**/*.js") + " + resources/shared/**/*.htm!text", saveTo: "resources-shared" },
{ what: jsGlob("scheduling/shared/**/*.js") + " + scheduling/shared/**/*.htm!text", saveTo: "scheduling-shared" },
{
what: jsGlob("tasks/shared/**/*.js") + " + tasks/shared/**/*.htm!text - @contacts-labels-store - @tasks-labels-store - " + fileUploadExclusion,
saveTo: "tasks-shared"
},
{ what: "shared/fileUpload + " + jsGlob("shared/fileupload/**/*.js") + " + shared/fileupload/**/*.htm!text", saveTo: "shared-fileupload" },
{
what: "[shared/knockout-extensions/**/*.js] - shared/knockout-extensions/knockout-extensions-all - knockout-handlebars",
saveTo: "shared-ko-remaining"
},
{ what: "bundles/shared/**/*.js - bundles/shared/vmBranch - bundles/shared/highcharts-bindings", saveTo: "bundles-shared-remaining" },
{ what: "shared/lang-extensions/array", saveTo: "shared-langextensions-array" }
],
/** Various shared utilities/libraries not otherwise bundled. */
utilsToBuild: [
"shared/highcharts/highcharts",
"shared/highcharts/highcharts3d - shared/highcharts/highcharts",
"shared/highcharts/highcharts-nodata - shared/highcharts/highcharts",
"bundles/shared/highcharts-bindings - shared/highcharts/highcharts - shared/highcharts/highcharts-nodata",
"knockout-handlebars",
"bundles/shared/vmBranch - bundles/shared/graphTypes - widgets/* - shared/*",
"notes/templates/templates - notes/components/**/*",
"shared/knockout-extensions/knockout-extensions-all"
],
dupWhitelist: ["contacts/details/view/metadataac.js"]
};
//endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment