Skip to content

Commit 3ab084a

Browse files
committed
[#7] Build with spread operator polyfill
1 parent d5c4c5c commit 3ab084a

10 files changed

+112
-26
lines changed

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Radek Altof
3+
Copyright (c) 2021 Radek Altof
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: dist/lang-router.esm.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
/**
2-
* vue-lang-router v1.2.5
3-
* (c) 2020 Radek Altof
2+
* vue-lang-router v1.3.0
3+
* (c) 2021 Radek Altof
44
* Released under the MIT License.
55
*/
66

77
import VueI18n from 'vue-i18n';
88
import VueRouter from 'vue-router';
99

10+
function mergeObjects() {
11+
var arguments$1 = arguments;
12+
var targetObject = {};
13+
for (var i = 0; i < arguments.length; i++) {
14+
var sourceObject = arguments$1[i];
15+
for (var key in sourceObject) {
16+
if (Object.prototype.hasOwnProperty.call(sourceObject, key)) {
17+
targetObject[key] = sourceObject[key];
18+
}
19+
}
20+
}
21+
return targetObject;
22+
}
23+
var _spread = Object.assign || mergeObjects;
24+
1025
var script = {
1126
name: 'LocalizedLink',
1227
props: [ 'to' ],
@@ -271,11 +286,10 @@ LangRouter.install = function (Vue, options) {
271286
}
272287
}
273288
}
274-
i18n = new VueI18n({
275-
locale: defaultLanguage,
289+
i18n = new VueI18n(_spread({}, {locale: defaultLanguage,
276290
fallbackLocale: defaultLanguage,
277-
messages: messages,
278-
});
291+
messages: messages},
292+
options.i18nOptions));
279293
Vue.prototype._langRouter = { translations: translations };
280294
Vue.prototype.$localizePath = localizePath;
281295
Vue.component('localized-link', __vue_component__);

Diff for: dist/lang-router.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* vue-lang-router v1.2.5
3-
* (c) 2020 Radek Altof
2+
* vue-lang-router v1.3.0
3+
* (c) 2021 Radek Altof
44
* Released under the MIT License.
55
*/
66

@@ -10,6 +10,21 @@ var LangRouter = (function (exports, VueI18n, VueRouter) {
1010
VueI18n = VueI18n && Object.prototype.hasOwnProperty.call(VueI18n, 'default') ? VueI18n['default'] : VueI18n;
1111
VueRouter = VueRouter && Object.prototype.hasOwnProperty.call(VueRouter, 'default') ? VueRouter['default'] : VueRouter;
1212

13+
function mergeObjects() {
14+
var arguments$1 = arguments;
15+
var targetObject = {};
16+
for (var i = 0; i < arguments.length; i++) {
17+
var sourceObject = arguments$1[i];
18+
for (var key in sourceObject) {
19+
if (Object.prototype.hasOwnProperty.call(sourceObject, key)) {
20+
targetObject[key] = sourceObject[key];
21+
}
22+
}
23+
}
24+
return targetObject;
25+
}
26+
var _spread = Object.assign || mergeObjects;
27+
1328
var script = {
1429
name: 'LocalizedLink',
1530
props: [ 'to' ],
@@ -274,11 +289,10 @@ var LangRouter = (function (exports, VueI18n, VueRouter) {
274289
}
275290
}
276291
}
277-
exports.i18n = new VueI18n({
278-
locale: defaultLanguage,
292+
exports.i18n = new VueI18n(_spread({}, {locale: defaultLanguage,
279293
fallbackLocale: defaultLanguage,
280-
messages: messages,
281-
});
294+
messages: messages},
295+
options.i18nOptions));
282296
Vue.prototype._langRouter = { translations: translations };
283297
Vue.prototype.$localizePath = localizePath;
284298
Vue.component('localized-link', __vue_component__);

Diff for: dist/lang-router.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/lang-router.umd.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* vue-lang-router v1.2.5
3-
* (c) 2020 Radek Altof
2+
* vue-lang-router v1.3.0
3+
* (c) 2021 Radek Altof
44
* Released under the MIT License.
55
*/
66

@@ -13,6 +13,21 @@
1313
VueI18n = VueI18n && Object.prototype.hasOwnProperty.call(VueI18n, 'default') ? VueI18n['default'] : VueI18n;
1414
VueRouter = VueRouter && Object.prototype.hasOwnProperty.call(VueRouter, 'default') ? VueRouter['default'] : VueRouter;
1515

16+
function mergeObjects() {
17+
var arguments$1 = arguments;
18+
var targetObject = {};
19+
for (var i = 0; i < arguments.length; i++) {
20+
var sourceObject = arguments$1[i];
21+
for (var key in sourceObject) {
22+
if (Object.prototype.hasOwnProperty.call(sourceObject, key)) {
23+
targetObject[key] = sourceObject[key];
24+
}
25+
}
26+
}
27+
return targetObject;
28+
}
29+
var _spread = Object.assign || mergeObjects;
30+
1631
var script = {
1732
name: 'LocalizedLink',
1833
props: [ 'to' ],
@@ -277,11 +292,10 @@
277292
}
278293
}
279294
}
280-
exports.i18n = new VueI18n({
281-
locale: defaultLanguage,
295+
exports.i18n = new VueI18n(_spread({}, {locale: defaultLanguage,
282296
fallbackLocale: defaultLanguage,
283-
messages: messages,
284-
});
297+
messages: messages},
298+
options.i18nOptions));
285299
Vue.prototype._langRouter = { translations: translations };
286300
Vue.prototype.$localizePath = localizePath;
287301
Vue.component('localized-link', __vue_component__);

Diff for: helpers/spread-polyfill.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function mergeObjects() {
2+
let targetObject = {};
3+
4+
for (let i = 0; i < arguments.length; i++) {
5+
let sourceObject = arguments[i];
6+
7+
for (let key in sourceObject) {
8+
if (Object.prototype.hasOwnProperty.call(sourceObject, key)) {
9+
targetObject[key] = sourceObject[key];
10+
}
11+
}
12+
}
13+
14+
return targetObject;
15+
}
16+
17+
const _spread = Object.assign || mergeObjects;
18+
export default _spread;

Diff for: package-lock.json

+20-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-lang-router",
3-
"version": "1.2.5",
3+
"version": "1.3.0",
44
"description": "Vue.js language routing with (optional) URL localization",
55
"author": {
66
"name": "Radek Altof",
@@ -30,6 +30,7 @@
3030
"@radek-altof/lint-config": "^1.1.0",
3131
"@rollup/plugin-buble": "^0.21.3",
3232
"@rollup/plugin-commonjs": "^11.1.0",
33+
"@rollup/plugin-inject": "^4.0.2",
3334
"@vue/cli-plugin-babel": "~4.3.0",
3435
"@vue/cli-plugin-eslint": "~4.3.0",
3536
"@vue/cli-plugin-router": "~4.3.0",

Diff for: rollup.banner.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
vue-lang-router v<%= pkg.version %>
2-
(c) 2020 <%= pkg.author.name %>
2+
(c) 2021 <%= pkg.author.name %>
33
Released under the <%= pkg.license %> License.

Diff for: rollup.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import buble from '@rollup/plugin-buble'; // Transpile/polyfill with reasonable
44
import banner from 'rollup-plugin-banner'; // Add header to compiled JS files
55
import { terser } from 'rollup-plugin-terser'; // Minification
66
import cleanup from 'rollup-plugin-cleanup'; // Code cleanup
7+
import inject from '@rollup/plugin-inject'; // Import injection
78

89
const path = require('path');
910

@@ -56,7 +57,12 @@ export default {
5657
isProduction: true, // Force productiom mode
5758
},
5859
}),
59-
buble(), // Transpile to ES5
60+
buble({
61+
objectAssign: '_spread', // Polyfill for spread operator
62+
}),
63+
inject({
64+
'_spread': path.resolve('helpers/spread-polyfill.js'),
65+
}),
6066
banner({
6167
file: path.join(__dirname, 'rollup.banner.txt'),
6268
}),

0 commit comments

Comments
 (0)