Skip to content

Commit 254939e

Browse files
committed
feat!: drop IE 11 and modernize browser targets
BREAKING CHANGE: Drop IE 11, Safari 8, iOS 8, Android 4.4 browser support. Minimum browser targets are now rolling modern versions aligned with Shopify Online Store themes. The library now emits ES2015+ JavaScript (native classes, arrow functions, template literals) and no longer transpiles to ES5. - Update browserslist to union of @shopify/browserslist-config + Theme Store requirements - Remove 15 Babel ES5 transform plugins + dead @babel/plugin-external-helpers - Remove 7 polyfill imports from buybutton.js (whatwg-fetch, core-js/*) - Replace UglifyJS with terser for ES2015+-compatible minification - Add terser error guard against silent minification failure - Keep @babel/plugin-transform-modules-commonjs for Browserify test pipeline (until PR 7a) - Native ES2015 classes replace loose-mode Babel classes (non-enumerable prototype methods) - Create major changeset for 4.0.0 version bump - Pin pnpm/action-setup to commit SHA in ci.yml (supply chain hardening) - Add @changesets/changelog-github as explicit devDependency (was phantom)
1 parent e600961 commit 254939e

9 files changed

Lines changed: 108 additions & 470 deletions

File tree

.babelrc

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,15 @@
11
{
2+
"presets": [
3+
["@babel/preset-typescript", {
4+
"isTSX": false,
5+
"allExtensions": true
6+
}]
7+
],
28
"env": {
3-
"production": {
4-
"presets": [
5-
["@babel/preset-typescript", {
6-
"isTSX": false,
7-
"allExtensions": true
8-
}]
9-
],
10-
"plugins": [
11-
"@babel/plugin-transform-template-literals",
12-
"@babel/plugin-transform-literals",
13-
"@babel/plugin-transform-function-name",
14-
"@babel/plugin-transform-arrow-functions",
15-
"@babel/plugin-transform-block-scoped-functions",
16-
["@babel/plugin-transform-classes", {
17-
"loose": true
18-
}],
19-
"@babel/plugin-transform-object-super",
20-
"@babel/plugin-transform-shorthand-properties",
21-
"@babel/plugin-transform-duplicate-keys",
22-
"@babel/plugin-transform-computed-properties",
23-
"@babel/plugin-transform-spread",
24-
"@babel/plugin-transform-parameters",
25-
"@babel/plugin-transform-destructuring",
26-
"@babel/plugin-transform-block-scoping",
27-
"@babel/plugin-transform-typeof-symbol"
28-
]
29-
},
309
"development": {
31-
"presets": [
32-
["@babel/preset-typescript", {
33-
"isTSX": false,
34-
"allExtensions": true
35-
}]
36-
],
3710
"plugins": [
38-
"@babel/plugin-transform-modules-commonjs",
39-
"@babel/plugin-transform-template-literals",
40-
"@babel/plugin-transform-literals",
41-
"@babel/plugin-transform-function-name",
42-
"@babel/plugin-transform-arrow-functions",
43-
"@babel/plugin-transform-block-scoped-functions",
44-
["@babel/plugin-transform-classes", {
45-
"loose": true
46-
}],
47-
"@babel/plugin-transform-object-super",
48-
"@babel/plugin-transform-shorthand-properties",
49-
"@babel/plugin-transform-duplicate-keys",
50-
"@babel/plugin-transform-computed-properties",
51-
"@babel/plugin-transform-spread",
52-
"@babel/plugin-transform-parameters",
53-
"@babel/plugin-transform-destructuring",
54-
"@babel/plugin-transform-block-scoping",
55-
"@babel/plugin-transform-typeof-symbol"
11+
"@babel/plugin-transform-modules-commonjs"
5612
]
5713
}
5814
}
59-
}
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@shopify/buy-button-js": major
3+
---
4+
5+
Drop IE 11, Safari 8, iOS 8, Android 4.4 browser support. Minimum browser targets are now rolling modern versions aligned with Shopify Online Store themes. The library now emits ES2015+ JavaScript (native classes, arrow functions, template literals) and no longer transpiles to ES5.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@v3
1616

1717
- name: Setup pnpm
18-
uses: pnpm/action-setup@v4
18+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
1919

2020
- name: Setup Node.js
2121
uses: actions/setup-node@v3
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/checkout@v3
4949

5050
- name: Setup pnpm
51-
uses: pnpm/action-setup@v4
51+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
5252

5353
- name: Setup Node.js
5454
uses: actions/setup-node@v3

docs/tasks/prd-typescript-migration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This document outlines the requirements for migrating the Buy Button JS applicat
1111
### Status
1212

1313
- **Phases 1-2 (Infrastructure + Type Definitions):** Complete. PRs [#926](https://github.com/Shopify/buy-button-js/pull/926) and [#927](https://github.com/Shopify/buy-button-js/pull/927) merged.
14-
- **Phase 3 (Tooling Modernization):** Not started.
14+
- **Phase 3 (Tooling Modernization):** In progress. PR 3 (pnpm) submitted as [PR #942](https://github.com/Shopify/buy-button-js/pull/942). PR 4 (browser targets) submitted as PR 4a ([#945](https://github.com/Shopify/buy-button-js/pull/945)) + PR 4b ([#946](https://github.com/Shopify/buy-button-js/pull/946)).
1515
- **Phase 4 (Source File Conversion):** Not started. 49 JS files remain in `src/`.
1616
- **Phase 5 (Test File Conversion):** Not started. 30 test JS files remain.
1717

@@ -185,7 +185,7 @@ All 49 source files are categorized by dependency depth. Each tier must be conve
185185
| Area | Current | Target | Rationale |
186186
|------|---------|--------|-----------|
187187
| Package manager | Yarn v1 (1.x) | pnpm | Faster, stricter dependency resolution, better monorepo support, actively maintained |
188-
| Browser targets | IE 11, Safari 8, iOS 8, Android 4.4 | Rolling modern targets | Eliminates 16 Babel transform plugins + all polyfills (~30-50KB bundle savings). Major version bump required. |
188+
| Browser targets | IE 11, Safari 8, iOS 8, Android 4.4 | Rolling modern targets | Eliminates 15 Babel ES5 transform plugins + all polyfills (~30-50KB bundle savings). Major version bump required. `@babel/plugin-transform-modules-commonjs` retained for Browserify test pipeline until PR 7a. |
189189
| Build system | Rollup 1.18.0 + Babel 7.5 + UglifyJS | Vite library mode | Native TS support, ESM-first, tree-shaking, faster builds. UglifyJS can't parse ES2015+ (blocks IE 11 drop). |
190190
| Test framework | Mocha 6.2 + Testem 2.17 + Chai 4.2 + Sinon 7.4 + Browserify | Vitest + happy-dom | Native TS support, ESM-first, fast, built-in coverage, compatible assertion API. Eliminates Browserify test pipeline. |
191191
| Linting | ESLint 3.3.1 + eslint-plugin-shopify | ESLint 9 flat config + @typescript-eslint | Modern TS rules, enforces `no-explicit-any`, replaces unmaintained Shopify plugin |
@@ -211,7 +211,7 @@ All 49 source files are categorized by dependency depth. Each tier must be conve
211211
**Rationale:** Buy-button-js is embedded on merchant storefronts — the same browser environment as the theme itself. If the theme works, the buy button must work. Auto-advancing rolling targets mean zero maintenance.
212212

213213
Dropping legacy browsers enables:
214-
1. Remove 16 Babel transform plugins (all target ES5 output)
214+
1. Remove 15 Babel ES5 transform plugins (retain `@babel/plugin-transform-modules-commonjs` for Browserify test pipeline until PR 7a)
215215
2. Replace UglifyJS with terser as interim minifier (UglifyJS can't parse ES2015+ — blocking the Vite migration). Terser is removed once Vite handles minification.
216216
3. Remove 7 polyfill imports from `buybutton.js` (`whatwg-fetch` + 6 `core-js` modules)
217217
4. Native ES2015+ output — classes, arrow functions, template literals, destructuring
@@ -306,7 +306,7 @@ These are key checkpoints where the executor should perform manual verification
306306
|-------|-------------|-----|--------|
307307
| 1 | TypeScript Infrastructure Setup | 1 (PR 1) | Complete |
308308
| 2 | Type Definitions | 1 (PR 2) | Complete |
309-
| 3 | Tooling Modernization | 7 (PRs 3-8, with 7 split into 7a/7b) | Not started |
309+
| 3 | Tooling Modernization | 7 (PRs 3-8, with 7 split into 7a/7b) | In progress (PRs 3-4 submitted) |
310310
| 4 | TypeScript File Conversion | 13 (PRs 9-21) | Not started |
311311
| 5 | Test File Conversion | 6 (PRs 22-26, with 25 split into 25a/25b) | Not started |
312312

docs/tasks/tasks-prd-typescript-migration.md

Lines changed: 30 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This migration is structured across ~28 PRs in 5 phases. Phases 1-2 are complete
66

77
**Exit criteria for every PR:** `pnpm test` passes, `pnpm run build` produces correct bundles, `pnpm run type-check` passes, `pnpm run lint` passes.
88

9-
**Note on package manager commands:** All commands in this document use `pnpm` (the target state after PR 3). Before PR 3 is complete, the project uses Yarn (`yarn test`, `yarn run build`, etc.). The `pretest` script in package.json also uses `npm run` — this should be updated to `pnpm run` in PR 3.
9+
**Note on package manager commands:** All commands in this document use `pnpm`, which is the active package manager since PR 3.
1010

1111
## Source File Inventory (49 files)
1212

@@ -196,82 +196,47 @@ Use Graphite (gt) commands for managing stacked branches:
196196

197197
---
198198

199-
- [ ] 3. Migrate Yarn v1 → pnpm (PR 3)
199+
- [x] 3. Migrate Yarn v1 → pnpm (PR 3) — [PR #942](https://github.com/Shopify/buy-button-js/pull/942)
200200

201-
- [ ] 3.1. Create new branch using `gt create typescript-migration-part-3`
201+
- [x] 3.1. Create new branch using `gt create typescript-migration-part-3`
202202

203-
- [ ] 3.2. Install pnpm and initialize `pnpm-lock.yaml`; delete `yarn.lock`
203+
- [x] 3.2. Install pnpm and initialize `pnpm-lock.yaml`; delete `yarn.lock`
204204

205-
- [ ] 3.3. Update `package.json` scripts: replace all `yarn run` with `pnpm run`, replace `yarn` with `pnpm`. Fix `pretest` script which uses `npm run``pnpm run`
205+
- [x] 3.3. Update `package.json` scripts: replace all `yarn run` with `pnpm run`, replace `yarn` with `pnpm`. Fix `pretest` script which uses `npm run``pnpm run`
206206

207-
- [ ] 3.4. Update `.github/workflows/ci.yml`: replace `npm install`/`npm run`/`npm test` with pnpm equivalents. Add pnpm setup step.
207+
- [x] 3.4. Update `.github/workflows/ci.yml`: replace `npm install`/`npm run`/`npm test` with pnpm equivalents. Add pnpm setup step.
208208

209209
- [ ] 3.5. Update `.github/workflows/npm-release.yml`: replace `yarn install` with `pnpm install`, `npx changeset` with `pnpx changeset`. Add pnpm setup step.
210210

211-
- [ ] 3.6. Update `.github/workflows/snapit.yml`: same pattern — replace yarn/npm with pnpm equivalents. Add pnpm setup step.
211+
- [x] 3.6. Update `.github/workflows/snapit.yml`: same pattern — replace yarn/npm with pnpm equivalents. Add pnpm setup step.
212212

213-
- [ ] 3.7. Verify: `pnpm test` passes, `pnpm run build` produces correct output, `pnpm run type-check` passes
213+
- [x] 3.7. Verify: `pnpm test` passes, `pnpm run build` produces correct output, `pnpm run type-check` passes
214214

215-
- [ ] 3.8. **[PR BOUNDARY]** Submit PR 3 using `gt submit`
215+
- [x] 3.8. **[PR BOUNDARY]** Submit PR 3 using `gt submit`
216216

217-
- [ ] 4. Drop IE 11 + Modernize Browser Targets — MAJOR VERSION BUMP (PR 4)
217+
- [x] 4. Drop IE 11 + Modernize Browser Targets — MAJOR VERSION BUMP (PR 4) — PR 4a: [PR #945](https://github.com/Shopify/buy-button-js/pull/945), PR 4b: [PR #946](https://github.com/Shopify/buy-button-js/pull/946)
218218

219-
- [ ] 4.1. Create new branch using `gt create typescript-migration-part-4`
219+
- [x] 4.1. Create new branch using `gt create typescript-migration-part-4`
220220

221-
- [ ] 4.2. Update `package.json` and create changeset:
221+
- [x] 4.2. Update `package.json` and create changeset:
222222
- Create a major changeset via `pnpm changeset` (select `major` bump) with description: "Drop IE 11, Safari 8, iOS 8, Android 4.4 browser support. Minimum browser targets are now rolling modern versions aligned with Shopify Online Store themes." Do NOT edit `version` in package.json directly — changesets manages this.
223-
- Replace `browserslist` with modern rolling targets:
224-
```json
225-
"browserslist": [
226-
"last 3 Chrome versions",
227-
"last 3 Firefox versions",
228-
"last 3 Safari versions",
229-
"last 2 Edge versions",
230-
"last 3 ChromeAndroid versions",
231-
"last 3 iOS versions",
232-
"last 2 Samsung versions",
233-
"not dead"
234-
]
235-
```
236-
237-
- [ ] 4.3. Update `.babelrc`: remove 16 transform plugins (15 production + 1 development-only):
238-
- `@babel/plugin-transform-arrow-functions`
239-
- `@babel/plugin-transform-block-scoped-functions`
240-
- `@babel/plugin-transform-block-scoping`
241-
- `@babel/plugin-transform-classes`
242-
- `@babel/plugin-transform-computed-properties`
243-
- `@babel/plugin-transform-destructuring`
244-
- `@babel/plugin-transform-duplicate-keys`
245-
- `@babel/plugin-transform-function-name`
246-
- `@babel/plugin-transform-literals`
247-
- `@babel/plugin-transform-object-super`
248-
- `@babel/plugin-transform-parameters`
249-
- `@babel/plugin-transform-shorthand-properties`
250-
- `@babel/plugin-transform-spread`
251-
- `@babel/plugin-transform-template-literals`
252-
- `@babel/plugin-transform-typeof-symbol`
253-
- `@babel/plugin-transform-modules-commonjs` (development env)
254-
255-
- [ ] 4.4. Remove polyfill imports from `src/buybutton.js`:
256-
- `whatwg-fetch`
257-
- `core-js/features/promise`
258-
- `core-js/features/string/ends-with`
259-
- `core-js/features/array/iterator`
260-
- `core-js/features/array/find`
261-
- `core-js/features/object/assign`
262-
- `core-js/features/object/values`
263-
264-
- [ ] 4.5. Remove polyfill dependencies from `package.json`: `core-js`, `whatwg-fetch`
265-
266-
- [ ] 4.6. Replace UglifyJS with terser in `script/build.js`: Install `terser` as devDep, replace `uglify-js` calls with terser equivalents. Terser supports ES2015+ syntax (unlike UglifyJS) and serves as the interim minifier until Vite replaces the build pipeline in PR 6.
267-
268-
- [ ] 4.7. Remove UglifyJS from dependencies: `uglify-js`
269-
270-
- [ ] 4.8. Update `CHANGELOG.md` documenting the breaking change (IE 11 drop)
271-
272-
- [ ] 4.9. Verify: `pnpm test` passes, `pnpm run build` produces correct output, `pnpm run type-check` passes
273-
274-
- [ ] 4.10. **[PR BOUNDARY]** Submit PR 4 using `gt submit`
223+
- Replace `browserslist` with modern rolling targets (union of `@shopify/browserslist-config` + Theme Store requirements)
224+
225+
- [x] 4.3. Update `.babelrc`: remove 15 ES5 transform plugins; retain `@babel/plugin-transform-modules-commonjs` in development env for Browserify test pipeline (removed in PR 7a)
226+
227+
- [x] 4.4. Remove polyfill imports from `src/buybutton.js` (7 imports: `whatwg-fetch` + 6 `core-js` modules)
228+
229+
- [x] 4.5. Remove polyfill dependencies from `package.json`: `core-js`, `whatwg-fetch`
230+
231+
- [x] 4.6. Replace UglifyJS with terser in `script/build.js`: Install `terser` as devDep, replace `uglify-js` calls with terser equivalents. Terser supports ES2015+ syntax (unlike UglifyJS) and serves as the interim minifier until Vite replaces the build pipeline in PR 6.
232+
233+
- [x] 4.7. Remove UglifyJS from dependencies: `uglify-js`
234+
235+
- [x] 4.8. CHANGELOG breaking change is documented via major changeset (automatic CHANGELOG generation enabled in PR 4a)
236+
237+
- [x] 4.9. Verify: `pnpm test` passes, `pnpm run build` produces correct output, `pnpm run type-check` passes
238+
239+
- [x] 4.10. **[PR BOUNDARY]** Submit PR 4 using `gt submit`
275240

276241
- [ ] 5. ESLint 3.3.1 → ESLint 9 Flat Config + @typescript-eslint (PR 5)
277242

@@ -784,7 +749,7 @@ Since Vitest natively handles both `.js` and `.ts` test files, test conversion i
784749
## Important Learnings from Initial Setup
785750

786751
### Package Manager
787-
**CRITICAL:** This project currently uses **Yarn v1**, but will migrate to **pnpm** in PR 3. Until PR 3 is complete, use `yarn` commands. After PR 3, use `pnpm` exclusively.
752+
This project uses **pnpm** (migrated from Yarn v1 in PR 3).
788753

789754
### Build System Architecture
790755
- Currently: Rollup with Babel for builds (migrates to Vite in PR 6)

package.json

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
"name": "@shopify/buy-button-js",
33
"version": "3.0.6",
44
"browserslist": [
5-
"last 2 Chrome versions",
6-
"last 2 Firefox versions",
7-
"last 2 versions",
8-
"Safari >= 8",
9-
"iOS >= 8",
10-
"IE >= 11",
11-
"android >= 4.4"
5+
"last 3 Chrome versions",
6+
"last 3 Firefox versions",
7+
"last 3 Safari versions",
8+
"last 3 Edge versions",
9+
"last 3 Opera versions",
10+
"last 3 ChromeAndroid versions",
11+
"last 1 FirefoxAndroid versions",
12+
"ios >= 13.4",
13+
"last 2 Samsung versions",
14+
"not dead"
1215
],
1316
"description": "BuyButton.js allows merchants to build Shopify interfaces into any website",
1417
"main": "lib/buybutton.umd.js",
@@ -54,23 +57,7 @@
5457
"devDependencies": {
5558
"@babel/cli": "7.5.5",
5659
"@babel/core": "7.5.5",
57-
"@babel/plugin-external-helpers": "7.2.0",
58-
"@babel/plugin-transform-arrow-functions": "7.2.0",
59-
"@babel/plugin-transform-block-scoped-functions": "7.2.0",
60-
"@babel/plugin-transform-block-scoping": "7.5.5",
61-
"@babel/plugin-transform-classes": "7.5.5",
62-
"@babel/plugin-transform-computed-properties": "7.2.0",
63-
"@babel/plugin-transform-destructuring": "7.5.0",
64-
"@babel/plugin-transform-duplicate-keys": "7.5.0",
65-
"@babel/plugin-transform-function-name": "7.4.4",
66-
"@babel/plugin-transform-literals": "7.2.0",
6760
"@babel/plugin-transform-modules-commonjs": "7.5.0",
68-
"@babel/plugin-transform-object-super": "7.5.5",
69-
"@babel/plugin-transform-parameters": "7.4.4",
70-
"@babel/plugin-transform-shorthand-properties": "7.2.0",
71-
"@babel/plugin-transform-spread": "7.2.2",
72-
"@babel/plugin-transform-template-literals": "7.4.4",
73-
"@babel/plugin-transform-typeof-symbol": "7.2.0",
7461
"@babel/preset-typescript": "^7.27.1",
7562
"@changesets/changelog-github": "^0.6.0",
7663
"@changesets/cli": "^2.28.1",
@@ -80,7 +67,6 @@
8067
"aws-sdk": "2.6.8",
8168
"babelify": "10.0.0",
8269
"chai": "4.2.0",
83-
"core-js": "3.1.4",
8470
"eslint": "3.3.1",
8571
"eslint-plugin-shopify": "13.0",
8672
"fetch-pretender": "1.5.0",
@@ -98,20 +84,19 @@
9884
"rollup-plugin-commonjs": "10.0.1",
9985
"rollup-plugin-node-resolve": "5.2.0",
10086
"sinon": "7.4.1",
87+
"terser": "^5.39.0",
10188
"testem": "2.17.0",
10289
"typescript": "^5.9.2",
10390
"watch": "1.0.2",
10491
"watchify": "3.11.1",
105-
"webdriverio": "4.2.8",
106-
"whatwg-fetch": "3.0.0"
92+
"webdriverio": "4.2.8"
10793
},
10894
"dependencies": {
10995
"@babel/runtime": "7.18.9",
11096
"browserify": "16.3.0",
11197
"morphdom": "2.6.1",
11298
"mustache": "3.0.1",
11399
"sass": "1.69.0",
114-
"shopify-buy": "3.0.7",
115-
"uglify-js": "3.16.3"
100+
"shopify-buy": "3.0.7"
116101
}
117102
}

0 commit comments

Comments
 (0)