feat: add Intl.Segmenter polyfill (#3688)
This commit is contained in:
@@ -84,6 +84,7 @@ export const createConfiguration: (
|
|||||||
experiments: {
|
experiments: {
|
||||||
topLevelAwait: true,
|
topLevelAwait: true,
|
||||||
outputModule: false,
|
outputModule: false,
|
||||||
|
syncWebAssembly: true,
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
environment: {
|
environment: {
|
||||||
|
|||||||
@@ -15,21 +15,24 @@ export default async function (cli_env: any, _: any) {
|
|||||||
const config = createConfiguration(flags, runtimeConfig);
|
const config = createConfiguration(flags, runtimeConfig);
|
||||||
return merge(config, {
|
return merge(config, {
|
||||||
entry: {
|
entry: {
|
||||||
|
'polyfill/intl-segmenter': {
|
||||||
|
import: resolve(rootPath, 'src/polyfill/intl-segmenter.ts'),
|
||||||
|
},
|
||||||
'polyfill/ses': {
|
'polyfill/ses': {
|
||||||
import: resolve(rootPath, 'src/polyfill/ses.ts'),
|
import: resolve(rootPath, 'src/polyfill/ses.ts'),
|
||||||
},
|
},
|
||||||
plugin: {
|
plugin: {
|
||||||
dependOn: ['polyfill/ses'],
|
dependOn: ['polyfill/intl-segmenter', 'polyfill/ses'],
|
||||||
import: resolve(rootPath, 'src/bootstrap/register-plugins.ts'),
|
import: resolve(rootPath, 'src/bootstrap/register-plugins.ts'),
|
||||||
},
|
},
|
||||||
app: {
|
app: {
|
||||||
chunkLoading: 'import',
|
chunkLoading: 'import',
|
||||||
dependOn: ['polyfill/ses', 'plugin'],
|
dependOn: ['polyfill/intl-segmenter', 'polyfill/ses', 'plugin'],
|
||||||
import: resolve(rootPath, 'src/index.tsx'),
|
import: resolve(rootPath, 'src/index.tsx'),
|
||||||
},
|
},
|
||||||
'_plugin/index.test': {
|
'_plugin/index.test': {
|
||||||
chunkLoading: 'import',
|
chunkLoading: 'import',
|
||||||
dependOn: ['polyfill/ses', 'plugin'],
|
dependOn: ['polyfill/intl-segmenter', 'polyfill/ses', 'plugin'],
|
||||||
import: resolve(rootPath, 'src/_plugin/index.test.tsx'),
|
import: resolve(rootPath, 'src/_plugin/index.test.tsx'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -39,7 +42,7 @@ export default async function (cli_env: any, _: any) {
|
|||||||
inject: 'body',
|
inject: 'body',
|
||||||
scriptLoading: 'module',
|
scriptLoading: 'module',
|
||||||
minify: false,
|
minify: false,
|
||||||
chunks: ['app', 'plugin', 'polyfill/ses'],
|
chunks: ['app', 'plugin', 'polyfill/intl-segmenter', 'polyfill/ses'],
|
||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
}),
|
}),
|
||||||
new HTMLPlugin({
|
new HTMLPlugin({
|
||||||
@@ -47,7 +50,12 @@ export default async function (cli_env: any, _: any) {
|
|||||||
inject: 'body',
|
inject: 'body',
|
||||||
scriptLoading: 'module',
|
scriptLoading: 'module',
|
||||||
minify: false,
|
minify: false,
|
||||||
chunks: ['_plugin/index.test', 'plugin', 'polyfill/ses'],
|
chunks: [
|
||||||
|
'_plugin/index.test',
|
||||||
|
'plugin',
|
||||||
|
'polyfill/intl-segmenter',
|
||||||
|
'polyfill/ses',
|
||||||
|
],
|
||||||
filename: '_plugin/index.html',
|
filename: '_plugin/index.html',
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"css-spring": "^4.1.0",
|
"css-spring": "^4.1.0",
|
||||||
"cssnano": "^6.0.1",
|
"cssnano": "^6.0.1",
|
||||||
"graphql": "^16.7.1",
|
"graphql": "^16.7.1",
|
||||||
|
"intl-segmenter-polyfill-rs": "^0.1.5",
|
||||||
"jotai": "^2.2.2",
|
"jotai": "^2.2.2",
|
||||||
"jotai-devtools": "^0.6.1",
|
"jotai-devtools": "^0.6.1",
|
||||||
"lit": "^2.7.6",
|
"lit": "^2.7.6",
|
||||||
|
|||||||
11
apps/core/src/polyfill/intl-segmenter.ts
Normal file
11
apps/core/src/polyfill/intl-segmenter.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
if (Intl.Segmenter === undefined) {
|
||||||
|
await import('intl-segmenter-polyfill-rs').then(({ Segmenter }) => {
|
||||||
|
Object.defineProperty(Intl, 'Segmenter', {
|
||||||
|
value: Segmenter,
|
||||||
|
configurable: true,
|
||||||
|
writable: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
@@ -257,6 +257,7 @@ __metadata:
|
|||||||
express: ^4.18.2
|
express: ^4.18.2
|
||||||
graphql: ^16.7.1
|
graphql: ^16.7.1
|
||||||
html-webpack-plugin: ^5.5.3
|
html-webpack-plugin: ^5.5.3
|
||||||
|
intl-segmenter-polyfill-rs: ^0.1.5
|
||||||
jotai: ^2.2.2
|
jotai: ^2.2.2
|
||||||
jotai-devtools: ^0.6.1
|
jotai-devtools: ^0.6.1
|
||||||
lit: ^2.7.6
|
lit: ^2.7.6
|
||||||
@@ -21135,6 +21136,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"intl-segmenter-polyfill-rs@npm:^0.1.5":
|
||||||
|
version: 0.1.5
|
||||||
|
resolution: "intl-segmenter-polyfill-rs@npm:0.1.5"
|
||||||
|
checksum: 9cb27151a366d96eb26aa00d41fb2cb116500927eeaefb099161e328cf2fe18c68e9ed84310ad85c688f5600325ee7e925203f58f81773377997f596eec5dc5b
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"invariant@npm:^2.2.4":
|
"invariant@npm:^2.2.4":
|
||||||
version: 2.2.4
|
version: 2.2.4
|
||||||
resolution: "invariant@npm:2.2.4"
|
resolution: "invariant@npm:2.2.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user