Skip to content

Commit

Permalink
Remove unused Intl.Segmenter polyfill (#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Nov 1, 2023
1 parent 4bf1719 commit 9fb2051
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 24 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"expo-system-ui": "~2.4.0",
"expo-updates": "~0.18.12",
"fast-text-encoding": "^1.0.6",
"graphemer": "^1.4.0",
"history": "^5.3.0",
"js-sha256": "^0.9.0",
"lande": "^1.0.10",
Expand Down
16 changes: 0 additions & 16 deletions src/platform/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'fast-text-encoding'
import Graphemer from 'graphemer'
// @ts-ignore no decl -prf
import findLast from 'array.prototype.findlast'
export {}
Expand Down Expand Up @@ -54,18 +53,3 @@ globalThis.atob = (str: string): string => {
}
return result
}

const splitter = new Graphemer()
globalThis.Intl = globalThis.Intl || {}

// @ts-ignore we're polyfilling -prf
globalThis.Intl.Segmenter =
// @ts-ignore we're polyfilling -prf
globalThis.Intl.Segmenter ||
class Segmenter {
constructor() {}
// NOTE
// this is not a precisely correct polyfill but it's sufficient for our needs
// -prf
segment = splitter.iterateGraphemes
}
6 changes: 1 addition & 5 deletions src/platform/polyfills.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ window.setImmediate = (cb: () => void) => setTimeout(cb, 0)

// @ts-ignore not on the TS signature due to bad support -prf
if (!globalThis.Intl?.Segmenter) {
// NOTE loading as a separate script to reduce main bundle size, as this is only needed in FF -prf
const script = document.createElement('script')
script.setAttribute('src', '/static/js/intl-segmenter-polyfill.min.js')
document.head.appendChild(script)

// loading emoji mart data
// TODO: This condition doesn't make sense; emojimart has nothing to do with Intl.
const emojiMartScript = document.createElement('script')
emojiMartScript.setAttribute('src', '/static/js/emoji-mart-data.js')
document.head.appendChild(emojiMartScript)
Expand Down
2 changes: 0 additions & 2 deletions web/static/js/intl-segmenter-polyfill.min.js

This file was deleted.

0 comments on commit 9fb2051

Please sign in to comment.