Skip to content

Commit

Permalink
chore(build): use ESBuild as alternative build for Salesforce (#911)
Browse files Browse the repository at this point in the history
- assign jQuery to the window object so that we can bundle jQuery in the same slickgrid bundle, in other words we would only have 1 single static resource (zip) for the entire slickgrid-universal and that's it (since everything is bundled, jQuery and even SortableJS also become part of the bundle and aren't needed as extra resources)
  • Loading branch information
ghiscoding authored Feb 22, 2023
1 parent 8b84952 commit b1b19e5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/common/src/global-jquery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import jQuery from 'jquery';

// assign jQuery on the global window object
Object.assign(window, { $: jQuery, jQuery });
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './global-jquery';
import 'multiple-select-modified';

import * as BackendUtilities from './services/backendUtility.service';
Expand Down
Binary file not shown.
8 changes: 5 additions & 3 deletions packages/vanilla-force-bundle/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ build({
format: 'iife',
globalName: 'Slicker',
target: 'es2018',
external: ['jQuery'],
legalComments: 'external', // Move all legal comments to a .LEGAL.txt file
mainFields: ['module', 'main'],
sourcemap: true,
sourcemap: false,
sourcesContent: false,
logLevel: 'error',
outfile: 'dist/bundle/slickgrid-vanilla-bundle.js',
plugins: [excludeVendorFromSourceMapPlugin({ filter: /node_modules/ })]
plugins: [
// we don't need sourcemap in Salesforce since it can't be used from inside static resouce (zip)
excludeVendorFromSourceMapPlugin({ filter: /node_modules/ })
]
});
2 changes: 1 addition & 1 deletion packages/vanilla-force-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"bundle:commonjs": "tsc --project tsconfig.bundle.json --outDir dist/commonjs --module commonjs",
"bundle:esm": "tsc --project tsconfig.bundle.json --outDir dist/esm --module esnext --target es2018",
"bundle:types": "tsc --emitDeclarationOnly --declarationMap --outDir dist/types",
"bundle:web": "esbuild src/index.ts --bundle --minify --format=iife --sourcemap --sources-content=false --target=es2018 --main-fields=module,main --external:jquery --global-name=Slicker --outfile=dist/bundle/slickgrid-vanilla-bundle.js",
"bundle:web": "esbuild src/index.ts --bundle --minify --format=iife --sourcemap --sources-content=false --target=es2018 --main-fields=module,main --global-name=Slicker --outfile=dist/bundle/slickgrid-vanilla-bundle.js",
"bundle:web:esbuild": "node esbuild.mjs",
"prebundle:zip": "pnpm run delete:zip",
"bundle:zip": "pnpm run zip:dist",
Expand Down

0 comments on commit b1b19e5

Please sign in to comment.