@sveltejs/kit 1.0.0-next.320 → 1.0.0-next.323
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/client/start.js +1 -1
- package/assets/server/index.js +18 -16
- package/dist/chunks/index.js +1 -2
- package/dist/chunks/index2.js +8 -13
- package/dist/chunks/index4.js +2 -6
- package/dist/chunks/index5.js +2 -13
- package/dist/chunks/sync.js +11 -5
- package/dist/chunks/url.js +84 -2
- package/dist/cli.js +3 -3
- package/package.json +1 -1
- package/dist/chunks/object.js +0 -83
package/assets/client/start.js
CHANGED
|
@@ -112,7 +112,7 @@ function normalize_path(path, trailing_slash) {
|
|
|
112
112
|
|
|
113
113
|
if (trailing_slash === 'never') {
|
|
114
114
|
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
115
|
-
} else if (trailing_slash === 'always' &&
|
|
115
|
+
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
|
116
116
|
return path + '/';
|
|
117
117
|
}
|
|
118
118
|
|
package/assets/server/index.js
CHANGED
|
@@ -2045,7 +2045,7 @@ function normalize_path(path, trailing_slash) {
|
|
|
2045
2045
|
|
|
2046
2046
|
if (trailing_slash === 'never') {
|
|
2047
2047
|
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
2048
|
-
} else if (trailing_slash === 'always' &&
|
|
2048
|
+
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
|
2049
2049
|
return path + '/';
|
|
2050
2050
|
}
|
|
2051
2051
|
|
|
@@ -2792,7 +2792,7 @@ async function respond$1(opts) {
|
|
|
2792
2792
|
|
|
2793
2793
|
let stuff = {};
|
|
2794
2794
|
|
|
2795
|
-
ssr:
|
|
2795
|
+
ssr: {
|
|
2796
2796
|
for (let i = 0; i < nodes.length; i += 1) {
|
|
2797
2797
|
const node = nodes[i];
|
|
2798
2798
|
|
|
@@ -3098,20 +3098,6 @@ const default_transform = ({ html }) => html;
|
|
|
3098
3098
|
async function respond(request, options, state) {
|
|
3099
3099
|
let url = new URL(request.url);
|
|
3100
3100
|
|
|
3101
|
-
const normalized = normalize_path(url.pathname, options.trailing_slash);
|
|
3102
|
-
|
|
3103
|
-
if (normalized !== url.pathname && !state.prerender?.fallback) {
|
|
3104
|
-
return new Response(undefined, {
|
|
3105
|
-
status: 301,
|
|
3106
|
-
headers: {
|
|
3107
|
-
location:
|
|
3108
|
-
// ensure paths starting with '//' are not treated as protocol-relative
|
|
3109
|
-
(normalized.startsWith('//') ? url.origin + normalized : normalized) +
|
|
3110
|
-
(url.search === '?' ? '' : url.search)
|
|
3111
|
-
}
|
|
3112
|
-
});
|
|
3113
|
-
}
|
|
3114
|
-
|
|
3115
3101
|
const { parameter, allowed } = options.method_override;
|
|
3116
3102
|
const method_override = url.searchParams.get(parameter)?.toUpperCase();
|
|
3117
3103
|
|
|
@@ -3181,6 +3167,22 @@ async function respond(request, options, state) {
|
|
|
3181
3167
|
}
|
|
3182
3168
|
}
|
|
3183
3169
|
|
|
3170
|
+
if (route?.type === 'page') {
|
|
3171
|
+
const normalized = normalize_path(url.pathname, options.trailing_slash);
|
|
3172
|
+
|
|
3173
|
+
if (normalized !== url.pathname && !state.prerender?.fallback) {
|
|
3174
|
+
return new Response(undefined, {
|
|
3175
|
+
status: 301,
|
|
3176
|
+
headers: {
|
|
3177
|
+
location:
|
|
3178
|
+
// ensure paths starting with '//' are not treated as protocol-relative
|
|
3179
|
+
(normalized.startsWith('//') ? url.origin + normalized : normalized) +
|
|
3180
|
+
(url.search === '?' ? '' : url.search)
|
|
3181
|
+
}
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3184
3186
|
/** @type {import('types').RequestEvent} */
|
|
3185
3187
|
const event = {
|
|
3186
3188
|
get clientAddress() {
|
package/dist/chunks/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path__default from 'path';
|
|
2
2
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
3
|
import vite from 'vite';
|
|
4
|
-
import { d as deep_merge } from './
|
|
4
|
+
import { n as normalize_path, d as deep_merge } from './url.js';
|
|
5
5
|
import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as get_aliases, p as print_config_conflicts } from '../cli.js';
|
|
6
6
|
import fs__default from 'fs';
|
|
7
7
|
import { URL } from 'url';
|
|
@@ -12,7 +12,6 @@ import { getRequest, setResponse } from '../node.js';
|
|
|
12
12
|
import { sequence } from '../hooks.js';
|
|
13
13
|
import { p as posixify } from './filesystem.js';
|
|
14
14
|
import { p as parse_route_id } from './misc.js';
|
|
15
|
-
import { n as normalize_path } from './url.js';
|
|
16
15
|
import 'sade';
|
|
17
16
|
import 'child_process';
|
|
18
17
|
import 'net';
|
package/dist/chunks/index2.js
CHANGED
|
@@ -6,8 +6,7 @@ import { p as print_config_conflicts, b as get_aliases, r as resolve_entry, g as
|
|
|
6
6
|
import { g as generate_manifest } from './index3.js';
|
|
7
7
|
import vite from 'vite';
|
|
8
8
|
import { s } from './misc.js';
|
|
9
|
-
import { d as deep_merge } from './
|
|
10
|
-
import { n as normalize_path, r as resolve, i as is_root_relative } from './url.js';
|
|
9
|
+
import { n as normalize_path, d as deep_merge, r as resolve, i as is_root_relative } from './url.js';
|
|
11
10
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
12
11
|
import { pathToFileURL, URL as URL$1 } from 'url';
|
|
13
12
|
import { installFetch } from '../install-fetch.js';
|
|
@@ -39,16 +38,12 @@ async function build_service_worker(
|
|
|
39
38
|
prerendered,
|
|
40
39
|
client_manifest
|
|
41
40
|
) {
|
|
42
|
-
|
|
43
|
-
const app_files = new Set();
|
|
41
|
+
const build = new Set();
|
|
44
42
|
for (const key in client_manifest) {
|
|
45
|
-
const { file, css } = client_manifest[key];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
app_files.add(file);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
43
|
+
const { file, css = [], assets = [] } = client_manifest[key];
|
|
44
|
+
build.add(file);
|
|
45
|
+
css.forEach((file) => build.add(file));
|
|
46
|
+
assets.forEach((file) => build.add(file));
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
const service_worker = `${config.kit.outDir}/generated/service-worker.js`;
|
|
@@ -64,7 +59,7 @@ async function build_service_worker(
|
|
|
64
59
|
};
|
|
65
60
|
|
|
66
61
|
export const build = [
|
|
67
|
-
${Array.from(
|
|
62
|
+
${Array.from(build)
|
|
68
63
|
.map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/${file}`)}`)
|
|
69
64
|
.join(',\n\t\t\t\t')}
|
|
70
65
|
];
|
|
@@ -461,7 +456,7 @@ async function build_server(
|
|
|
461
456
|
|
|
462
457
|
const default_config = {
|
|
463
458
|
build: {
|
|
464
|
-
target: '
|
|
459
|
+
target: 'node14.8'
|
|
465
460
|
},
|
|
466
461
|
ssr: {
|
|
467
462
|
// when developing against the Kit src code, we want to ensure that
|
package/dist/chunks/index4.js
CHANGED
|
@@ -130,9 +130,7 @@ function create_builder({ config, build_data, prerendered, log }) {
|
|
|
130
130
|
},
|
|
131
131
|
|
|
132
132
|
writeClient(dest) {
|
|
133
|
-
return copy(`${config.kit.outDir}/output/client`, dest
|
|
134
|
-
filter: (file) => file[0] !== '.'
|
|
135
|
-
});
|
|
133
|
+
return copy(`${config.kit.outDir}/output/client`, dest);
|
|
136
134
|
},
|
|
137
135
|
|
|
138
136
|
writePrerendered(dest, { fallback } = {}) {
|
|
@@ -148,9 +146,7 @@ function create_builder({ config, build_data, prerendered, log }) {
|
|
|
148
146
|
},
|
|
149
147
|
|
|
150
148
|
writeServer(dest) {
|
|
151
|
-
return copy(`${config.kit.outDir}/output/server`, dest
|
|
152
|
-
filter: (file) => file[0] !== '.'
|
|
153
|
-
});
|
|
149
|
+
return copy(`${config.kit.outDir}/output/server`, dest);
|
|
154
150
|
},
|
|
155
151
|
|
|
156
152
|
writeStatic(dest) {
|
package/dist/chunks/index5.js
CHANGED
|
@@ -6,7 +6,6 @@ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
7
|
import { getRequest, setResponse } from '../node.js';
|
|
8
8
|
import { installFetch } from '../install-fetch.js';
|
|
9
|
-
import { n as normalize_path } from './url.js';
|
|
10
9
|
import 'querystring';
|
|
11
10
|
import 'stream';
|
|
12
11
|
import 'node:http';
|
|
@@ -98,17 +97,7 @@ async function preview({ port, host, config, https: use_https = false }) {
|
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
const { pathname
|
|
102
|
-
|
|
103
|
-
const normalized = normalize_path(pathname, config.kit.trailingSlash);
|
|
104
|
-
|
|
105
|
-
if (normalized !== pathname) {
|
|
106
|
-
res.writeHead(307, {
|
|
107
|
-
location: base + normalized + search
|
|
108
|
-
});
|
|
109
|
-
res.end();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
100
|
+
const { pathname } = new URL(/** @type {string} */ (req.url), 'http://dummy');
|
|
112
101
|
|
|
113
102
|
// only treat this as a page if it doesn't include an extension
|
|
114
103
|
if (pathname === '/' || /\/[^./]+\/?$/.test(pathname)) {
|
|
@@ -169,7 +158,7 @@ async function preview({ port, host, config, https: use_https = false }) {
|
|
|
169
158
|
});
|
|
170
159
|
|
|
171
160
|
return new Promise((fulfil) => {
|
|
172
|
-
http_server.listen(port, host
|
|
161
|
+
http_server.listen(port, host, () => {
|
|
173
162
|
fulfil(http_server);
|
|
174
163
|
});
|
|
175
164
|
});
|
package/dist/chunks/sync.js
CHANGED
|
@@ -419,6 +419,10 @@ function trace(file, path, tree, extensions) {
|
|
|
419
419
|
const node = tree.get(parts.join('/'));
|
|
420
420
|
const layout = node?.layouts[layout_id];
|
|
421
421
|
|
|
422
|
+
if (layout?.file && layouts.indexOf(layout.file) > -1) {
|
|
423
|
+
throw new Error(`Recursive layout detected: ${layout.file} -> ${layouts.join(' -> ')}`);
|
|
424
|
+
}
|
|
425
|
+
|
|
422
426
|
// any segment that has neither a __layout nor an __error can be discarded.
|
|
423
427
|
// in other words these...
|
|
424
428
|
// layouts: [a, , b, c]
|
|
@@ -791,10 +795,12 @@ function write_tsconfig(config) {
|
|
|
791
795
|
compilerOptions: {
|
|
792
796
|
// generated options
|
|
793
797
|
baseUrl: config_relative('.'),
|
|
794
|
-
paths:
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
+
paths: fs__default.existsSync(config.kit.files.lib)
|
|
799
|
+
? {
|
|
800
|
+
$lib: [project_relative(config.kit.files.lib)],
|
|
801
|
+
'$lib/*': [project_relative(config.kit.files.lib + '/*')]
|
|
802
|
+
}
|
|
803
|
+
: {},
|
|
798
804
|
rootDirs: [config_relative('.'), './types'],
|
|
799
805
|
|
|
800
806
|
// essential options
|
|
@@ -833,7 +839,7 @@ function validate(config, out, user_file) {
|
|
|
833
839
|
if (extends_framework_config) {
|
|
834
840
|
const { paths: user_paths } = user_tsconfig.compilerOptions || {};
|
|
835
841
|
|
|
836
|
-
if (user_paths) {
|
|
842
|
+
if (user_paths && fs__default.existsSync(config.kit.files.lib)) {
|
|
837
843
|
/** @type {string[]} */
|
|
838
844
|
const lib = user_paths['$lib'] || [];
|
|
839
845
|
/** @type {string[]} */
|
package/dist/chunks/url.js
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes zero or more objects and returns a new object that has all the values
|
|
3
|
+
* deeply merged together. None of the original objects will be mutated at any
|
|
4
|
+
* level, and the returned object will have no references to the original
|
|
5
|
+
* objects at any depth. If there's a conflict the last one wins, except for
|
|
6
|
+
* arrays which will be combined.
|
|
7
|
+
* @param {...Object} objects
|
|
8
|
+
* @returns {[Record<string, any>, string[]]} a 2-tuple with the merged object,
|
|
9
|
+
* and a list of merge conflicts if there were any, in dotted notation
|
|
10
|
+
*/
|
|
11
|
+
function deep_merge(...objects) {
|
|
12
|
+
const result = {};
|
|
13
|
+
/** @type {string[]} */
|
|
14
|
+
const conflicts = [];
|
|
15
|
+
objects.forEach((o) => merge_into(result, o, conflicts));
|
|
16
|
+
return [result, conflicts];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* normalize kit.vite.resolve.alias as an array
|
|
21
|
+
* @param {import('vite').AliasOptions} o
|
|
22
|
+
* @returns {import('vite').Alias[]}
|
|
23
|
+
*/
|
|
24
|
+
function normalize_alias(o) {
|
|
25
|
+
if (Array.isArray(o)) return o;
|
|
26
|
+
return Object.entries(o).map(([find, replacement]) => ({ find, replacement }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Merges b into a, recursively, mutating a.
|
|
31
|
+
* @param {Record<string, any>} a
|
|
32
|
+
* @param {Record<string, any>} b
|
|
33
|
+
* @param {string[]} conflicts array to accumulate conflicts in
|
|
34
|
+
* @param {string[]} path array of property names representing the current
|
|
35
|
+
* location in the tree
|
|
36
|
+
*/
|
|
37
|
+
function merge_into(a, b, conflicts = [], path = []) {
|
|
38
|
+
/**
|
|
39
|
+
* Checks for "plain old Javascript object", typically made as an object
|
|
40
|
+
* literal. Excludes Arrays and built-in types like Buffer.
|
|
41
|
+
* @param {any} x
|
|
42
|
+
*/
|
|
43
|
+
const is_plain_object = (x) => typeof x === 'object' && x.constructor === Object;
|
|
44
|
+
|
|
45
|
+
for (const prop in b) {
|
|
46
|
+
// normalize alias objects to array
|
|
47
|
+
if (prop === 'alias' && path[path.length - 1] === 'resolve') {
|
|
48
|
+
if (a[prop]) a[prop] = normalize_alias(a[prop]);
|
|
49
|
+
if (b[prop]) b[prop] = normalize_alias(b[prop]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (is_plain_object(b[prop])) {
|
|
53
|
+
if (!is_plain_object(a[prop])) {
|
|
54
|
+
if (a[prop] !== undefined) {
|
|
55
|
+
conflicts.push([...path, prop].join('.'));
|
|
56
|
+
}
|
|
57
|
+
a[prop] = {};
|
|
58
|
+
}
|
|
59
|
+
merge_into(a[prop], b[prop], conflicts, [...path, prop]);
|
|
60
|
+
} else if (Array.isArray(b[prop])) {
|
|
61
|
+
if (!Array.isArray(a[prop])) {
|
|
62
|
+
if (a[prop] !== undefined) {
|
|
63
|
+
conflicts.push([...path, prop].join('.'));
|
|
64
|
+
}
|
|
65
|
+
a[prop] = [];
|
|
66
|
+
}
|
|
67
|
+
a[prop].push(...b[prop]);
|
|
68
|
+
} else {
|
|
69
|
+
// Since we're inside a for/in loop which loops over enumerable
|
|
70
|
+
// properties only, we want parity here and to check if 'a' has
|
|
71
|
+
// enumerable-only property 'prop'. Using 'hasOwnProperty' to
|
|
72
|
+
// exclude inherited properties is close enough. It is possible
|
|
73
|
+
// that someone uses Object.defineProperty to create a direct,
|
|
74
|
+
// non-enumerable property but let's not worry about that.
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(a, prop)) {
|
|
76
|
+
conflicts.push([...path, prop].join('.'));
|
|
77
|
+
}
|
|
78
|
+
a[prop] = b[prop];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
1
83
|
const absolute = /^([a-z]+:)?\/?\//;
|
|
2
84
|
const scheme = /^[a-z]+:/;
|
|
3
85
|
|
|
@@ -46,11 +128,11 @@ function normalize_path(path, trailing_slash) {
|
|
|
46
128
|
|
|
47
129
|
if (trailing_slash === 'never') {
|
|
48
130
|
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
49
|
-
} else if (trailing_slash === 'always' &&
|
|
131
|
+
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
|
50
132
|
return path + '/';
|
|
51
133
|
}
|
|
52
134
|
|
|
53
135
|
return path;
|
|
54
136
|
}
|
|
55
137
|
|
|
56
|
-
export { is_root_relative as i, normalize_path as n, resolve as r };
|
|
138
|
+
export { deep_merge as d, is_root_relative as i, normalize_path as n, resolve as r };
|
package/dist/cli.js
CHANGED
|
@@ -459,7 +459,7 @@ const options = object(
|
|
|
459
459
|
|
|
460
460
|
if (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {
|
|
461
461
|
throw new Error(
|
|
462
|
-
`${keypath} option must be a root-relative path that starts but doesn't end with '/'. See https://kit.svelte.dev/docs/configuration#paths`
|
|
462
|
+
`${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://kit.svelte.dev/docs/configuration#paths`
|
|
463
463
|
);
|
|
464
464
|
}
|
|
465
465
|
|
|
@@ -870,7 +870,7 @@ async function launch(port, https, base) {
|
|
|
870
870
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
871
871
|
}
|
|
872
872
|
|
|
873
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
873
|
+
const prog = sade('svelte-kit').version('1.0.0-next.323');
|
|
874
874
|
|
|
875
875
|
prog
|
|
876
876
|
.command('dev')
|
|
@@ -1049,7 +1049,7 @@ async function check_port(port) {
|
|
|
1049
1049
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1050
1050
|
if (open) launch(port, https, base);
|
|
1051
1051
|
|
|
1052
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1052
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.323'}\n`));
|
|
1053
1053
|
|
|
1054
1054
|
const protocol = https ? 'https:' : 'http:';
|
|
1055
1055
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/package.json
CHANGED
package/dist/chunks/object.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Takes zero or more objects and returns a new object that has all the values
|
|
3
|
-
* deeply merged together. None of the original objects will be mutated at any
|
|
4
|
-
* level, and the returned object will have no references to the original
|
|
5
|
-
* objects at any depth. If there's a conflict the last one wins, except for
|
|
6
|
-
* arrays which will be combined.
|
|
7
|
-
* @param {...Object} objects
|
|
8
|
-
* @returns {[Record<string, any>, string[]]} a 2-tuple with the merged object,
|
|
9
|
-
* and a list of merge conflicts if there were any, in dotted notation
|
|
10
|
-
*/
|
|
11
|
-
function deep_merge(...objects) {
|
|
12
|
-
const result = {};
|
|
13
|
-
/** @type {string[]} */
|
|
14
|
-
const conflicts = [];
|
|
15
|
-
objects.forEach((o) => merge_into(result, o, conflicts));
|
|
16
|
-
return [result, conflicts];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* normalize kit.vite.resolve.alias as an array
|
|
21
|
-
* @param {import('vite').AliasOptions} o
|
|
22
|
-
* @returns {import('vite').Alias[]}
|
|
23
|
-
*/
|
|
24
|
-
function normalize_alias(o) {
|
|
25
|
-
if (Array.isArray(o)) return o;
|
|
26
|
-
return Object.entries(o).map(([find, replacement]) => ({ find, replacement }));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Merges b into a, recursively, mutating a.
|
|
31
|
-
* @param {Record<string, any>} a
|
|
32
|
-
* @param {Record<string, any>} b
|
|
33
|
-
* @param {string[]} conflicts array to accumulate conflicts in
|
|
34
|
-
* @param {string[]} path array of property names representing the current
|
|
35
|
-
* location in the tree
|
|
36
|
-
*/
|
|
37
|
-
function merge_into(a, b, conflicts = [], path = []) {
|
|
38
|
-
/**
|
|
39
|
-
* Checks for "plain old Javascript object", typically made as an object
|
|
40
|
-
* literal. Excludes Arrays and built-in types like Buffer.
|
|
41
|
-
* @param {any} x
|
|
42
|
-
*/
|
|
43
|
-
const is_plain_object = (x) => typeof x === 'object' && x.constructor === Object;
|
|
44
|
-
|
|
45
|
-
for (const prop in b) {
|
|
46
|
-
// normalize alias objects to array
|
|
47
|
-
if (prop === 'alias' && path[path.length - 1] === 'resolve') {
|
|
48
|
-
if (a[prop]) a[prop] = normalize_alias(a[prop]);
|
|
49
|
-
if (b[prop]) b[prop] = normalize_alias(b[prop]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (is_plain_object(b[prop])) {
|
|
53
|
-
if (!is_plain_object(a[prop])) {
|
|
54
|
-
if (a[prop] !== undefined) {
|
|
55
|
-
conflicts.push([...path, prop].join('.'));
|
|
56
|
-
}
|
|
57
|
-
a[prop] = {};
|
|
58
|
-
}
|
|
59
|
-
merge_into(a[prop], b[prop], conflicts, [...path, prop]);
|
|
60
|
-
} else if (Array.isArray(b[prop])) {
|
|
61
|
-
if (!Array.isArray(a[prop])) {
|
|
62
|
-
if (a[prop] !== undefined) {
|
|
63
|
-
conflicts.push([...path, prop].join('.'));
|
|
64
|
-
}
|
|
65
|
-
a[prop] = [];
|
|
66
|
-
}
|
|
67
|
-
a[prop].push(...b[prop]);
|
|
68
|
-
} else {
|
|
69
|
-
// Since we're inside a for/in loop which loops over enumerable
|
|
70
|
-
// properties only, we want parity here and to check if 'a' has
|
|
71
|
-
// enumerable-only property 'prop'. Using 'hasOwnProperty' to
|
|
72
|
-
// exclude inherited properties is close enough. It is possible
|
|
73
|
-
// that someone uses Object.defineProperty to create a direct,
|
|
74
|
-
// non-enumerable property but let's not worry about that.
|
|
75
|
-
if (Object.prototype.hasOwnProperty.call(a, prop)) {
|
|
76
|
-
conflicts.push([...path, prop].join('.'));
|
|
77
|
-
}
|
|
78
|
-
a[prop] = b[prop];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { deep_merge as d };
|