fix: replace options.immutable and remove svelte v4 shim
This commit is contained in:
parent
b8d1deb982
commit
52f937795a
|
@ -76,7 +76,6 @@
|
|||
"devDependencies": {
|
||||
"@peculiar/webcrypto": "^1.4.3",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-inject": "^5.0.5",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-replace": "^5.0.5",
|
||||
"@rollup/plugin-strip": "^3.0.4",
|
||||
|
@ -103,7 +102,6 @@
|
|||
"jest-environment-jsdom": "^29.7.0",
|
||||
"lint-staged": "^15.1.0",
|
||||
"lodash-es": "^4.17.15",
|
||||
"magic-string": "^0.30.5",
|
||||
"markdown-table": "^3.0.2",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import MagicString from 'magic-string'
|
||||
import inject from '@rollup/plugin-inject'
|
||||
import cjs from '@rollup/plugin-commonjs'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
|
@ -57,6 +55,7 @@ const baseConfig = {
|
|||
'options.context': 'undefined',
|
||||
'options.customElement': 'undefined',
|
||||
'options.hydrate': 'undefined',
|
||||
'options.immutable': 'undefined',
|
||||
'options.intro': 'undefined',
|
||||
delimiters: ['', ''],
|
||||
preventAssignment: true
|
||||
|
@ -98,28 +97,6 @@ const entryPoints = [
|
|||
input: './src/picker/PickerElement.js',
|
||||
output: './svelte.js',
|
||||
external: ['svelte', 'svelte/internal'],
|
||||
// TODO: drop Svelte v3 support
|
||||
// ensure_array_like was added in Svelte v4 - we shim it to avoid breaking Svelte v3 users
|
||||
plugins: [
|
||||
{
|
||||
name: 'svelte-v3-compat',
|
||||
transform (source) {
|
||||
const magicString = new MagicString(source)
|
||||
magicString.replaceAll('ensure_array_like(', 'ensure_array_like_shim(')
|
||||
|
||||
return {
|
||||
code: magicString.toString(),
|
||||
map: magicString.generateMap()
|
||||
}
|
||||
}
|
||||
},
|
||||
inject({
|
||||
ensure_array_like_shim: [
|
||||
'../../../../shims/svelte-v3-shim.js',
|
||||
'ensure_array_like_shim'
|
||||
]
|
||||
})
|
||||
],
|
||||
onwarn (warning) {
|
||||
if (!warning.message.includes('ensure_array_like')) { // intentionally ignore warning for unused import
|
||||
console.warn(warning.message)
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
// TODO: drop Svelte v3 support
|
||||
// ensure_array_like was added in Svelte v4 - we shim it to avoid breaking Svelte v3 users
|
||||
// this code is copied from svelte v4
|
||||
/* eslint-disable camelcase */
|
||||
export function ensure_array_like_shim (array_like_or_iterator) {
|
||||
return (array_like_or_iterator && array_like_or_iterator.length !== undefined)
|
||||
? array_like_or_iterator
|
||||
: Array.from(array_like_or_iterator)
|
||||
}
|
11
yarn.lock
11
yarn.lock
|
@ -723,15 +723,6 @@
|
|||
is-reference "1.2.1"
|
||||
magic-string "^0.30.3"
|
||||
|
||||
"@rollup/plugin-inject@^5.0.5":
|
||||
version "5.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-5.0.5.tgz#616f3a73fe075765f91c5bec90176608bed277a3"
|
||||
integrity sha512-2+DEJbNBoPROPkgTDNe8/1YXWcqxbN5DTjASVIOx8HS+pITXushyNiBV56RB08zuptzz8gT3YfkqriTBVycepg==
|
||||
dependencies:
|
||||
"@rollup/pluginutils" "^5.0.1"
|
||||
estree-walker "^2.0.2"
|
||||
magic-string "^0.30.3"
|
||||
|
||||
"@rollup/plugin-node-resolve@^15.2.3":
|
||||
version "15.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz#e5e0b059bd85ca57489492f295ce88c2d4b0daf9"
|
||||
|
@ -5469,7 +5460,7 @@ magic-string@^0.27.0:
|
|||
dependencies:
|
||||
"@jridgewell/sourcemap-codec" "^1.4.13"
|
||||
|
||||
magic-string@^0.30.3, magic-string@^0.30.4, magic-string@^0.30.5:
|
||||
magic-string@^0.30.3, magic-string@^0.30.4:
|
||||
version "0.30.5"
|
||||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.5.tgz#1994d980bd1c8835dc6e78db7cbd4ae4f24746f9"
|
||||
integrity sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==
|
||||
|
|
Loading…
Reference in New Issue