Skip to content

Commit

Permalink
[Chore] Fix Issues with Browser Example (#751)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ajimae authored Aug 6, 2024
1 parent f37e181 commit d192943
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.14.0
20.15.0
31 changes: 31 additions & 0 deletions esbuild.cjs
Original file line number Diff line number Diff line change
@@ -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);
10 changes: 6 additions & 4 deletions examples/browser/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@


<button id="btnDetails" onclick="getProjectDetails()">Get Project Details</button>
<p id="details"></p>
<pre>
<p id="details"></p>
</pre>

<script>
(function() {
function getProjectDetails() {
var oauthUri = 'https://auth.europe-west1.gcp.commercetools.com'
var baseUri = 'https://api.europe-west1.gcp.commercetools.com'
var credentials = {
Expand All @@ -37,9 +39,9 @@
.get()
.execute()
.then(function ({ body }) {
window.document.getElementById('details').innerHTML = JSON.stringify(body);
window.document.getElementById('details').innerHTML = JSON.stringify(body, null, 2);
})
}())
}
</script>
</body>

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"changeset": "changeset",
"test:unit": "yarn test --testPathIgnorePatterns='packages/platform-sdk/test/integration-tests'",
"test:integration": "jest --testPathPattern='packages/platform-sdk/test/integration-tests'",
"postbuild": "webpack --mode=production",
"postbuild": "node esbuild.cjs",
"changeset:version-and-format": "changeset version && prettier --write --parser json '**/package.json'",
"docs": "rm -rf docs;typedoc"
},
Expand All @@ -35,6 +35,7 @@
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"codecov": "^3.2.5",
"esbuild": "^0.23.0",
"husky": "^8.0.0",
"ignore-loader": "^0.1.2",
"jest": "29.7.0",
Expand Down
86 changes: 0 additions & 86 deletions webpack.config.js

This file was deleted.

150 changes: 150 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,126 @@
resolved "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.0.tgz#145b74d5e4a5223489cabdc238d8dad902df5259"
integrity sha512-3sG8Zwa5fMcA9bgqB8AfWPQ+HFke6uD3h1s3RIwUNK8EG7a4buxvuFTs3j1IMs2NXAk9F30C/FF4vxRgQCcmoQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.23.0.tgz#453bbe079fc8d364d4c5545069e8260228559832"
integrity sha512-EuHFUYkAVfU4qBdyivULuu03FhJO4IJN9PGuABGrFy4vUuzk91P2d+npxHcFdpUnfYKy0PuV+n6bKIpHOB3prQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.23.0.tgz#26c806853aa4a4f7e683e519cd9d68e201ebcf99"
integrity sha512-+KuOHTKKyIKgEEqKbGTK8W7mPp+hKinbMBeEnNzjJGyFcWsfrXjSTNluJHCY1RqhxFurdD8uNXQDei7qDlR6+g==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.23.0.tgz#1e51af9a6ac1f7143769f7ee58df5b274ed202e6"
integrity sha512-WRrmKidLoKDl56LsbBMhzTTBxrsVwTKdNbKDalbEZr0tcsBgCLbEtoNthOW6PX942YiYq8HzEnb4yWQMLQuipQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.23.0.tgz#d996187a606c9534173ebd78c58098a44dd7ef9e"
integrity sha512-YLntie/IdS31H54Ogdn+v50NuoWF5BDkEUFpiOChVa9UnKpftgwzZRrI4J132ETIi+D8n6xh9IviFV3eXdxfow==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.23.0.tgz#30c8f28a7ef4e32fe46501434ebe6b0912e9e86c"
integrity sha512-IMQ6eme4AfznElesHUPDZ+teuGwoRmVuuixu7sv92ZkdQcPbsNHzutd+rAfaBKo8YK3IrBEi9SLLKWJdEvJniQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.0.tgz#30f4fcec8167c08a6e8af9fc14b66152232e7fb4"
integrity sha512-0muYWCng5vqaxobq6LB3YNtevDFSAZGlgtLoAc81PjUfiFz36n4KMpwhtAd4he8ToSI3TGyuhyx5xmiWNYZFyw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.23.0.tgz#1003a6668fe1f5d4439e6813e5b09a92981bc79d"
integrity sha512-XKDVu8IsD0/q3foBzsXGt/KjD/yTKBCIwOHE1XwiXmrRwrX6Hbnd5Eqn/WvDekddK21tfszBSrE/WMaZh+1buQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.23.0.tgz#3b9a56abfb1410bb6c9138790f062587df3e6e3a"
integrity sha512-j1t5iG8jE7BhonbsEg5d9qOYcVZv/Rv6tghaXM/Ug9xahM0nX/H2gfu6X6z11QRTMT6+aywOMA8TDkhPo8aCGw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.23.0.tgz#237a8548e3da2c48cd79ae339a588f03d1889aad"
integrity sha512-SEELSTEtOFu5LPykzA395Mc+54RMg1EUgXP+iw2SJ72+ooMwVsgfuwXo5Fn0wXNgWZsTVHwY2cg4Vi/bOD88qw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.23.0.tgz#4269cd19cb2de5de03a7ccfc8855dde3d284a238"
integrity sha512-P7O5Tkh2NbgIm2R6x1zGJJsnacDzTFcRWZyTTMgFdVit6E98LTxO+v8LCCLWRvPrjdzXHx9FEOA8oAZPyApWUA==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.23.0.tgz#82b568f5658a52580827cc891cb69d2cb4f86280"
integrity sha512-InQwepswq6urikQiIC/kkx412fqUZudBO4SYKu0N+tGhXRWUqAx+Q+341tFV6QdBifpjYgUndV1hhMq3WeJi7A==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.23.0.tgz#9a57386c926262ae9861c929a6023ed9d43f73e5"
integrity sha512-J9rflLtqdYrxHv2FqXE2i1ELgNjT+JFURt/uDMoPQLcjWQA5wDKgQA4t/dTqGa88ZVECKaD0TctwsUfHbVoi4w==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.23.0.tgz#f3a79fd636ba0c82285d227eb20ed8e31b4444f6"
integrity sha512-cShCXtEOVc5GxU0fM+dsFD10qZ5UpcQ8AM22bYj0u/yaAykWnqXJDpd77ublcX6vdDsWLuweeuSNZk4yUxZwtw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.23.0.tgz#f9d2ef8356ce6ce140f76029680558126b74c780"
integrity sha512-HEtaN7Y5UB4tZPeQmgz/UhzoEyYftbMXrBCUjINGjh3uil+rB/QzzpMshz3cNUxqXN7Vr93zzVtpIDL99t9aRw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.23.0.tgz#45390f12e802201f38a0229e216a6aed4351dfe8"
integrity sha512-WDi3+NVAuyjg/Wxi+o5KPqRbZY0QhI9TjrEEm+8dmpY9Xir8+HE/HNx2JoLckhKbFopW0RdO2D72w8trZOV+Wg==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.23.0.tgz#c8409761996e3f6db29abcf9b05bee8d7d80e910"
integrity sha512-a3pMQhUEJkITgAw6e0bWA+F+vFtCciMjW/LPtoj99MhVt+Mfb6bbL9hu2wmTZgNd994qTAEw+U/r6k3qHWWaOQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.23.0.tgz#ba70db0114380d5f6cfb9003f1d378ce989cd65c"
integrity sha512-cRK+YDem7lFTs2Q5nEv/HHc4LnrfBCbH5+JHu6wm2eP+d8OZNoSMYgPZJq78vqQ9g+9+nMuIsAO7skzphRXHyw==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.0.tgz#72fc55f0b189f7a882e3cf23f332370d69dfd5db"
integrity sha512-suXjq53gERueVWu0OKxzWqk7NxiUWSUlrxoZK7usiF50C6ipColGR5qie2496iKGYNLhDZkPxBI3erbnYkU0rQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.23.0.tgz#b6ae7a0911c18fe30da3db1d6d17a497a550e5d8"
integrity sha512-6p3nHpby0DM/v15IFKMjAaayFhqnXV52aEmv1whZHX56pdkK+MEaLoQWj+H42ssFarP1PcomVhbsR4pkz09qBg==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.23.0.tgz#58f0d5e55b9b21a086bfafaa29f62a3eb3470ad8"
integrity sha512-BFelBGfrBwk6LVrmFzCq1u1dZbG4zy/Kp93w2+y83Q5UGYF1d8sCzeLI9NXjKyujjBBniQa8R8PzLFAUrSM9OA==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.23.0.tgz#b858b2432edfad62e945d5c7c9e5ddd0f528ca6d"
integrity sha512-lY6AC8p4Cnb7xYHuIxQ6iYPe6MfO2CC43XXKo9nBXDb35krYt7KGhQnOkRGar5psxYkircpCqfbNDB4uJbS2jQ==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.23.0.tgz#167ef6ca22a476c6c0c014a58b4f43ae4b80dec7"
integrity sha512-7L1bHlOTcO4ByvI7OXVI5pNN6HSu6pUQq9yodga8izeuB1KcT2UkHaH6118QJwopExPn0rMHIseCTx1CRo/uNA==

"@esbuild/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.23.0.tgz#db44a6a08520b5f25bbe409f34a59f2d4bcc7ced"
integrity sha512-Arm+WgUFLUATuoxCJcahGuk6Yj9Pzxd6l11Zb/2aAuv5kWWvvfhLFo2fni4uSK5vzlUdCGZ/BdV5tH8klj8p8g==

"@grpc/grpc-js@^1.7.1":
version "1.10.7"
resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.10.7.tgz"
Expand Down Expand Up @@ -4906,6 +5026,36 @@ es-to-primitive@^1.2.1:
is-date-object "^1.0.1"
is-symbol "^1.0.2"

esbuild@^0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.23.0.tgz#de06002d48424d9fdb7eb52dbe8e95927f852599"
integrity sha512-1lvV17H2bMYda/WaFb2jLPeHU3zml2k4/yagNMG8Q/YtfMjCwEUZa2eXXMgZTVSL5q1n4H7sQ0X6CdJDqqeCFA==
optionalDependencies:
"@esbuild/aix-ppc64" "0.23.0"
"@esbuild/android-arm" "0.23.0"
"@esbuild/android-arm64" "0.23.0"
"@esbuild/android-x64" "0.23.0"
"@esbuild/darwin-arm64" "0.23.0"
"@esbuild/darwin-x64" "0.23.0"
"@esbuild/freebsd-arm64" "0.23.0"
"@esbuild/freebsd-x64" "0.23.0"
"@esbuild/linux-arm" "0.23.0"
"@esbuild/linux-arm64" "0.23.0"
"@esbuild/linux-ia32" "0.23.0"
"@esbuild/linux-loong64" "0.23.0"
"@esbuild/linux-mips64el" "0.23.0"
"@esbuild/linux-ppc64" "0.23.0"
"@esbuild/linux-riscv64" "0.23.0"
"@esbuild/linux-s390x" "0.23.0"
"@esbuild/linux-x64" "0.23.0"
"@esbuild/netbsd-x64" "0.23.0"
"@esbuild/openbsd-arm64" "0.23.0"
"@esbuild/openbsd-x64" "0.23.0"
"@esbuild/sunos-x64" "0.23.0"
"@esbuild/win32-arm64" "0.23.0"
"@esbuild/win32-ia32" "0.23.0"
"@esbuild/win32-x64" "0.23.0"

escalade@^3.1.1:
version "3.1.2"
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz"
Expand Down

0 comments on commit d192943

Please sign in to comment.