Skip to content

Commit 119969c

Browse files
fix: use $options suffix for configs
1 parent 9a923ec commit 119969c

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

lib/plugins/mdsvex/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports.default = {
1919
config: {
2020
mdsvex: conf,
2121
svelte: {
22-
preprocess: { mdsvex: conf },
22+
preprocess$options: { mdsvex: conf },
2323
preprocess$map: { mdsvex },
2424
extensions: [extension]
2525
}

lib/plugins/postcss/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212

1313
const postcssConfig = {
1414
plugins$map: { postcssImport },
15-
plugins: {
15+
plugins$options: {
1616
postcssImport: {},
1717
}
1818
}
@@ -24,7 +24,7 @@ export default {
2424

2525
// rollup needs access
2626
rollup: {
27-
plugins: { postcss: postcssConfig },
27+
plugins$options: { postcss: postcssConfig },
2828
plugins$map: { postcss }
2929
},
3030

lib/plugins/preprocess/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
app.merge({
99
config: {
1010
svelte: {
11-
preprocess: { autoPreprocess: {} },
11+
preprocess$options: { autoPreprocess: {} },
1212
preprocess$map: { autoPreprocess }
1313
}
1414
}

lib/plugins/rollup/rollup.template.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = function rollup(app, params) {
2525
format: 'esm', dir: buildDir
2626
},
2727
plugins$map: { svelte, resolve, commonjs, terser, hmr, livereload },
28-
plugins: {
28+
plugins$options: {
2929
terser: production && {},
3030
svelte: app.config.svelte,
3131
// resolve matching modules from current working directory

lib/plugins/svelte/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
config: {
88
svelte: {
99
extensions: ['.svelte'],
10-
preprocess: {},
10+
preprocess$options: {},
1111
preprocess$map: {}
1212
}
1313
}

lib/utils/index.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,25 @@ async function keysAsFunctionsRecursive(obj, suffix = '$map') {
4646
const maps = []
4747

4848
// process all descendants' maps first
49-
const children = Object.entries(obj).map(([key, value]) => {
49+
const children = Object.entries(obj).map(([mapKey, value]) => {
5050
if (isObject(value)) {
51-
if (key.endsWith(suffix))
52-
maps.push({ key, value })
51+
if (mapKey.endsWith(suffix))
52+
maps.push({ mapKey, value })
5353
else
5454
return keysAsFunctionsRecursive(value, suffix)
5555
}
5656
})
5757
await Promise.all(children)
5858

59-
// process own maps
60-
const ownMaps = await Promise.all(maps.map(async ({ key, value }) => {
61-
delete obj[key]
62-
key = key.substr(0, key.length - suffix.length)
63-
const result = await keysAsFunctions(obj[key], value, key)
64-
return {
65-
key,
66-
result
67-
}
59+
// process own maps. Need map instead of forEach for `await`
60+
await Promise.all(maps.map(async ({ mapKey, value }) => {
61+
const key = mapKey.substr(0, mapKey.length - suffix.length)
62+
const optionsKey = `${key}$options`
63+
const result = await keysAsFunctions(obj[optionsKey], value, key)
64+
delete obj[mapKey]
65+
delete obj[optionsKey]
66+
obj[key] = result
6867
}))
69-
ownMaps.forEach(thing => obj[thing.key] = thing.result)
7068

7169
return obj
7270
}

0 commit comments

Comments
 (0)