You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2.0-major-release.md
+4-77Lines changed: 4 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,63 +4,9 @@ The biggest change in Feathers-Vuex 2.0 is that it has been refactored with Type
4
4
5
5
Your project does NOT require to be written in TypeScript. The `dist` is compiled to ES6.
6
6
7
-
## Trying it out
7
+
## Fixing the build for older Vue-CLI Apps
8
8
9
-
I accidentally published `[email protected]` with a `pre` tag on npm, **you have to install the specific version number to get the latest code.** To find out which is the most-recently published version, run `npm view feathers-vuex` and look at the `pre` tag. You can ignore the `next` and `pegasus` tags. Those were accidents that happened because I publish a lot of packages. :)
Initially, I wasn't a fan of TypeScript. I'm turned off by the steeper learning curve it introduces to writing code.
36
-
37
-
What I do like is the tooling. It's like having an assistant that alerts you to stupid moves before you have to accidentally discover them yourself. I'm only able to appreciate it for one reason: you can use directives to tell it to ignore lines or files, similar to ESLint. The tooling will then shut up and let me write JavaScript. TypeScript has been quite beneficial to allowing me to better see how to refactor and get rid of a huge monkey patch. It's down to a few lines of code, now.
38
-
39
-
I imagine I will like TypeScript more when there's first-class support for it built into Vue. I imagine how powerful it will be in an entire Vue project. It's one of the reasons that I'm REALLY excited about the new VueJS 3.0 API (The new function-based syntax is way more exciting, though. It's going to let me write some really pretty, well-organized code :)
40
-
41
-
But that's enough about TypeScript.
42
-
43
-
## Where I need assistance: the build
44
-
45
-
The build system has been my only frustration with switching to TypeScript. Transpiling from TypeScript to JavaScript only to be transpiled by Babel (or whichever) into another form of JavaScript... has proven to be frustrating. I could really use some help in this area.
46
-
47
-
My original intent was to target the build to ES5. But there are some weird errors that show up when classes get transpiled into old Javascript code. Classes don't quite behave the same after transpiling. Things were so inconsistent that I couldn't write down any useful notes to tell you what I was experiencing. The only clarity I got out of the experience was that it was frustrating. ;)
48
-
49
-
I found that the simplest way around my frustration was to target ES6. I found next that Vue's default build assumes packages in the `node_modules` folder to be compiled to ES5. So you'll run into this error:
50
-
51
-
```text
52
-
TypeError : Class constructor BaseModel cannot be invoked without 'new'
53
-
```
54
-
55
-
This error was fixed by adding `feathers-vuex` to the `transpileDependencies` in the `vue.config.js` file:
56
-
57
-
```js
58
-
module.exports= {
59
-
transpileDependencies: ['feathers-vuex']
60
-
}
61
-
```
62
-
63
-
It felt like everything was solved until I ran the production build. There were more errors. I finally copied the `feathers-vuex` folder from `node_modules` into a `src/libs` folder in my project. Voila! It all works. So I'm currently running this code in production by using a shell script to copy it inside my project.
9
+
As of October 2019, up-to-date Vue-CLI apps are able to properly build and use `feathers-vuex` after adding `transpileDependencies`. For apps based on older modules, I've found the simplest solution to be to copy the `feathers-vuex` module into `src/libs` inside your project. Create a `copy-deps.sh` file in the root of your project and setup the following:
Then in `package.json`, create a script that uses the `copy-deps.sh` file:
74
20
75
21
```json
76
22
{
@@ -81,26 +27,7 @@ Then in my `package.json` scripts:
81
27
}
82
28
```
83
29
84
-
I don't consider the above solution to be a pretty one. I likely will not publish 2.0 until a solution is discovered which doesn't required copying from `node_modules`. I know it's got to be simple. It's has something to do with transpile settings for `node_modules`. I just haven't found it yet.
85
-
86
-
## Quasar Build
87
-
88
-
For Quasar apps, `transpileDependencies` can be updated in `quasar.conf.js` under build as
89
-
90
-
```
91
-
build: {
92
-
transpileDependencies: ['feathers-vuex']
93
-
}
94
-
```
95
-
96
-
## Nuxt Build
97
-
By default with Nuxt, the build server doesn't understand the word import, which is ES6 module syntax. You have to tell Nuxt in the config which node_modules to transpile from ES6 to ES5. (I tried avoiding this situation, but double transpilation while implementing classes can cause major issues at deployment time.) . Thankfully, the fix is easy in nuxt.config.js:
98
-
99
-
```
100
-
build: {
101
-
transpile: ['feathers-vuex'],
102
-
}
103
-
```
30
+
It's not the prettiest solution, but it works well and is the simplest for older apps.
IMPORTANT: Feathers-Vuex is (and requires to be) published in ES6 format for full compatibility with JS classes. If your project uses Babel, it must be configured properly. See the [Project Configuration](#projectconfiguration) section for more information.
58
+
57
59
### With feathers-socketio
58
60
59
61
A realtime-transport like Socket.io or Primus is required in order to take advantage of the real-time socket events built into Feathers-Vuex. The `feathers-hooks-common` package, specified below, is not required to work with Feathers-Vuex.
@@ -78,6 +80,39 @@ npm i @feathersjs/feathers @feathersjs/rest-client @feathersjs/authentication-cl
0 commit comments