Skip to content

Commit 99af896

Browse files
authored
Version conflict fixed between 2.x and 3.x (#108)
1 parent ffbc1db commit 99af896

9 files changed

+3362
-2280
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,21 @@ it('uses vue-wait component', () => {
735735
});
736736
```
737737

738+
## For Development on vue-wait
739+
Install packages
740+
```bash
741+
$ yarn install
742+
# or if you using npm
743+
$ npm install
744+
```
745+
746+
Bundle it
747+
```bash
748+
$ yarn bundle
749+
# or if you using npm
750+
$ npm run bundle
751+
```
752+
738753
## 🎯 Contributors
739754

740755
- Fatih Kadir Akın, (creator)

dist/vue-wait-next.js

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

dist/vue-wait-v2.js

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

dist/vue-wait.js

-1
This file was deleted.

index.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(function webpackUniversalModuleDefinition(root, factory) {
2+
if(typeof exports === 'object' && typeof module === 'object')
3+
module.exports = factory(require("vue"));
4+
else if(typeof define === 'function' && define.amd)
5+
define(["vue"], factory);
6+
else if(typeof exports === 'object')
7+
exports["VueWait"] = factory(require("vue"));
8+
else
9+
root["VueWait"] = factory(root["vue"]);
10+
})(typeof self !== 'undefined' ? self : this, function(vue) {
11+
if (vue.createApp) {
12+
const v3 = require('./dist/vue-wait-next');
13+
return v3
14+
}
15+
const v2 = require('./dist/vue-wait-v2');
16+
return v2
17+
})

package.json

+14-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"bugs": {
2121
"url": "https://github.com/f/vue-wait/issues"
2222
},
23-
"main": "dist/vue-wait.js",
23+
"main": "index.js",
2424
"types": "src/types/index.d.ts",
2525
"files": [
2626
"dist",
@@ -31,6 +31,7 @@
3131
"test": "exit 0;",
3232
"precommit": "lint-staged",
3333
"build": "cross-env NODE_ENV=production webpack --config webpack.config.js",
34+
"bundle": "npm run build; npm run build -- --env=v3",
3435
"dev-transition": "poi examples/transition-example/index.js",
3536
"dev-vuex": "poi examples/vuex-example/index.js",
3637
"dev-vue": "poi examples/vue-example/index.js",
@@ -48,10 +49,11 @@
4849
]
4950
},
5051
"devDependencies": {
51-
"@babel/core": "^7.0.0-beta.49",
52-
"@babel/plugin-transform-runtime": "^7.0.0-beta.49",
53-
"@babel/preset-env": "^7.0.0-beta.49",
54-
"babel-loader": "^8.0.0-beta.3",
52+
"@babel/core": "^7.14.8",
53+
"@babel/plugin-transform-runtime": "^7.14.5",
54+
"@babel/preset-env": "^7.14.8",
55+
"@vue/compiler-sfc": "^3.1.5",
56+
"babel-loader": "^8.2.2",
5557
"cross-env": "^5.1.3",
5658
"css-loader": "^0.28.11",
5759
"epic-spinners": "^1.0.3",
@@ -63,12 +65,13 @@
6365
"prettier": "^1.1.0",
6466
"uglifyjs-webpack-plugin": "^1.2.5",
6567
"vue-html-loader": "^1.2.4",
66-
"vue-loader": "^15.2.4",
67-
"vue-style-loader": "^4.1.0",
68-
"vue-template-compiler": "^2.5.16",
69-
"vuex": "^3.0.1",
70-
"webpack": "^4.11.1",
71-
"webpack-cli": "^3.0.2"
68+
"vue-loader": "^16.3.3",
69+
"vue-loader-old": "npm:vue-loader@^15.9.6",
70+
"vue-style-loader": "^4.1.3",
71+
"vue-template-compiler": "^2.6.14",
72+
"vuex": "^3.6.2",
73+
"webpack": "^5.47.0",
74+
"webpack-cli": "^4.7.2"
7275
},
7376
"peerDependencies": {
7477
"vue": "^2.5.16"

src/vue-wait.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default class VueWait {
3737
this.initialized = false;
3838
}
3939

40-
init(Vue, store) {
41-
if (nodeIsDebug() && !install.installed && VueWait.getVueVersion(Vue) < 3) {
40+
init(App, store) {
41+
if (nodeIsDebug() && !install.installed && VueWait.getVueVersion(App) < 3) {
4242
console.warn(
4343
`[vue-wait] not installed. Make sure to call \`Vue.use(VueWait)\` before init root instance.`
4444
);
@@ -49,11 +49,11 @@ export default class VueWait {
4949
}
5050

5151
if (this.options.registerComponent) {
52-
Vue.component(this.options.componentName, vWaitComponent);
52+
App.component(this.options.componentName, vWaitComponent);
5353
}
5454

5555
if (this.options.registerDirective) {
56-
Vue.directive(this.options.directiveName, vWaitDirective);
56+
App.directive(this.options.directiveName, vWaitDirective);
5757
}
5858

5959
if (this.options.useVuex) {
@@ -76,13 +76,13 @@ export default class VueWait {
7676
}
7777
};
7878

79-
if (VueWait.getVueVersion(Vue) > 2) {
79+
if (VueWait.getVueVersion(App) > 2) {
8080
const { createApp } = require('vue');
8181
this.stateHandler = createApp(config).mount(
8282
document.createElement('div')
8383
);
8484
} else {
85-
this.stateHandler = new Vue(config);
85+
this.stateHandler = new App(config);
8686
}
8787
} else {
8888
const config = {
@@ -117,13 +117,13 @@ export default class VueWait {
117117
}
118118
};
119119

120-
if (VueWait.getVueVersion(Vue) > 2) {
120+
if (VueWait.getVueVersion(App) > 2) {
121121
const { createApp } = require('vue');
122122
this.stateHandler = createApp(config).mount(
123123
document.createElement('div')
124124
);
125125
} else {
126-
this.stateHandler = new Vue(config);
126+
this.stateHandler = new App(config);
127127
}
128128
}
129129

@@ -192,8 +192,8 @@ export default class VueWait {
192192
}
193193
}
194194

195-
export function install(Vue) {
196-
if (install.installed && Vue) {
195+
export function install(App) {
196+
if (install.installed && App) {
197197
if (nodeIsDebug()) {
198198
console.warn(
199199
'[vue-wait] already installed. Vue.use(VueWait) should be called only once.'
@@ -202,7 +202,7 @@ export function install(Vue) {
202202
return;
203203
}
204204

205-
Vue.mixin({
205+
App.mixin({
206206
/**
207207
* VueWait init hook, injected into each instances init hooks list.
208208
*/
@@ -213,10 +213,10 @@ export function install(Vue) {
213213
if (wait) {
214214
instance = typeof wait === 'function' ? new wait() : wait;
215215
// Inject store
216-
instance.init(Vue, store);
216+
instance.init(App, store);
217217
} else if (parent && parent.__$waitInstance) {
218218
instance = parent.__$waitInstance;
219-
instance.init(Vue, parent.$store);
219+
instance.init(App, parent.$store);
220220
}
221221

222222
if (instance) {

webpack.config.js

+30-25
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1-
const { VueLoaderPlugin } = require("vue-loader");
1+
module.exports = env => {
2+
const isV3 = !!env.v3
3+
const loaderName = `vue-loader${isV3 ? '': '-old'}`;
4+
const { VueLoaderPlugin } = require(loaderName);
25

3-
module.exports = {
4-
mode: process.env.NODE_ENV,
5-
entry: ["./src/vue-wait.js"],
6-
output: {
7-
library: "VueWait",
8-
libraryTarget: "umd",
9-
filename: "vue-wait.js",
10-
globalObject: 'typeof self !== \'undefined\' ? self : this',
11-
},
12-
module: {
13-
rules: [
14-
{
15-
test: /\.vue$/,
16-
loader: "vue-loader"
17-
},
18-
{
19-
test: /\.js$/,
20-
exclude: /node_modules/,
21-
use: {
22-
loader: "babel-loader"
6+
return {
7+
mode: process.env.NODE_ENV,
8+
entry: ["./src/vue-wait.js"],
9+
output: {
10+
library: "VueWait",
11+
libraryTarget: "umd",
12+
globalObject: 'typeof self !== \'undefined\' ? self : this',
13+
filename: `vue-wait${isV3 ? '-next': '-v2'}.js`
14+
},
15+
externals: { vue: 'vue' },
16+
module: {
17+
rules: [
18+
{
19+
test: /\.vue$/,
20+
loader: loaderName
21+
},
22+
{
23+
test: /\.js$/,
24+
exclude: /node_modules/,
25+
use: {
26+
loader: "babel-loader"
27+
}
2328
}
24-
}
25-
]
26-
},
27-
plugins: [new VueLoaderPlugin()]
29+
]
30+
},
31+
plugins: [new VueLoaderPlugin()]
32+
}
2833
};

0 commit comments

Comments
 (0)