From d192943d65b2dd6fdd72a0ca7d6c2a392c86a2ad Mon Sep 17 00:00:00 2001 From: Ajima Chukwuemeka <32770340+ajimae@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:35:16 +0100 Subject: [PATCH] [Chore] Fix Issues with Browser Example (#751) * chore(browser.html): fix issues browser example - fix issues with browser example - replace webpack module bundle in favour of esbuild - minor refactor * chore(esbuild): remove unused variable - remove unused variable exec * chore(node-engine): ignore node engine ignore node engine check for now * chore(node-engine): ignore node engine ignore node engine check for now * chore(esbuild): fix typo errors - assign esbuild config to the correct variable name --- .circleci/config.yml | 2 +- .nvmrc | 2 +- esbuild.cjs | 31 +++++++ examples/browser/browser.html | 10 ++- package.json | 3 +- webpack.config.js | 86 ------------------- yarn.lock | 150 ++++++++++++++++++++++++++++++++++ 7 files changed, 191 insertions(+), 93 deletions(-) create mode 100644 esbuild.cjs delete mode 100644 webpack.config.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 8299749cf..2479ea484 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -75,7 +75,7 @@ jobs: - restore_cache: *restore_yarn_cache_node_16 - run: name: Installing dependencies - command: yarn install --frozen-lockfile + command: yarn install --ignore-engines --frozen-lockfile # temp ignore engine checks [will deprecate node v16 soon] - save_cache: *save_yarn_cache_node_16 - run: name: Install example dependencies diff --git a/.nvmrc b/.nvmrc index 805efa9f6..645ae0c87 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.14.0 \ No newline at end of file +20.15.0 \ No newline at end of file diff --git a/esbuild.cjs b/esbuild.cjs new file mode 100644 index 000000000..e1b5c02b3 --- /dev/null +++ b/esbuild.cjs @@ -0,0 +1,31 @@ +const esbuild = require('esbuild'); + +const generalConfig = { minify: true, bundle: true, write: true } + +const sdkClientConfig = esbuild.build( + Object.assign({}, generalConfig, { + entryPoints: ['packages/sdk-client/src/index.ts'], + globalName: 'window["@commercetools/sdk-client-v2"]', + outfile: 'packages/sdk-client/dist/commercetools-sdk-client-v2.umd.js' + }) +) + +const sdkClientV3Config = esbuild.build( + Object.assign({}, generalConfig, { + entryPoints: ['packages/sdk-client-v3/src/index.ts'], + globalName: 'window["@commercetools/ts-client"]', + outfile: 'packages/sdk-client-v3/dist/commercetools-ts-client.umd.js' + }) +) + +const platformSdkConfig = esbuild.build( + Object.assign({}, generalConfig, { + entryPoints: ['packages/platform-sdk/src/index.ts'], + globalName: 'window["@commercetools/platform-sdk"]', + outfile: 'packages/platform-sdk/dist/commercetools-platform-sdk.umd.js', + }) +) + +Promise.all([ + sdkClientConfig, sdkClientV3Config, platformSdkConfig +]).catch(console.error); diff --git a/examples/browser/browser.html b/examples/browser/browser.html index e0c5a88ce..31ba3b218 100644 --- a/examples/browser/browser.html +++ b/examples/browser/browser.html @@ -14,10 +14,12 @@ -
++ +