Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Yarn v3.0.0-rc2 #653

Merged
merged 14 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- name: Lint
run: |
yarn run lint --no-fix
DEBUG="lockfile-lint,validate-host-manager" npx lockfile-lint --path yarn.lock --validate-https --allowed-hosts npm --allowed-hosts registry.yarnpkg.com
- name: Test
run: |
yarn run coverage:unit
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ selenium-debug.log*
*.njsproj
*.sln
*.sw*

# Yarn
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
591 changes: 591 additions & 0 deletions .yarn/releases/yarn-3.0.0-rc.2.cjs

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs

enableNetwork: false
enableStrictSsl: true

networkSettings:
"registry.yarnpkg.com":
enableNetwork: true
"registry.npmjs.org":
enableNetwork: true
81 changes: 78 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,84 @@

## Building

This project was created with the [vue-cli](https://cli.vuejs.org/). Plugins
can be added through the vue-cli utility, and for building the project, you
can use one of the following commands.
This project was created with the [vue-cli](https://cli.vuejs.org/).

Vue CLI wraps Webpack, Babel, and other utilities. If you need to
customize Webpack, then you will have to modify the `vue.config.js`
file.

Its syntax is different than what you may find in Webpack documentation
or other websites.

```js
# webpack
module.exports = {
module: {
rules: [
{
test: /\.js$/,
loader: 'some-loader',
options: {
someOption: true
}
}
]
}
}

# vue.config.js
module.exports = {
chainWebpack: config => {
config.module.rule('js')
.test(/\.js$/)
.use('some-loader')
.loader('some-loader')
.options({
someOption: true
})
}
}
```

If you need to customize Babel, take a look at the `babel.config.js`
file. But if you want to transpile dependencies you must update the
`transpileDependencies` array in `vue.config.js`.

```js
# babel.config.js
module.exports = (api) => {
api.cache(true)
const presets = [
'@vue/app'
]
const plugins = [
['@babel/plugin-proposal-class-properties', { loose: true }]
]
return { presets, plugins }
}
```

The example above enables class properties (e.g. static properties used in
enumify's Enums) for the code. But dependencies are not transpiled. So you
will have to remember to update `vue.config.js`.

```js
# vue.config.js
module.exports = {
publicPath: '',
outputDir: 'dist',
indexPath: 'index.html',
transpileDependencies: [
// now the project should build fine, and the code in the dependency
// below can use class properties without any errors. Other dependencies
// are not transpiled, so if any of those dependencies use class
// properties in the exported code, then our build may fail, unless
// we include each library here.
'some-dependency-using-class-properties'
],
// ...
}
```

### Project setup

Expand Down
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/core": "^7.13.16",
"@babel/eslint-parser": "^7.13.14",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-optional-chaining": "^7.14.2",
"@cypress/code-coverage": "^3.9.5",
"@cypress/webpack-preprocessor": "^5.7.0",
"@mdi/js": "^5.9.55",
Expand All @@ -63,7 +66,9 @@
"@vue/cli-plugin-unit-mocha": "^4.5.13",
"@vue/cli-service": "^4.5.13",
"@vue/test-utils": "^1.2.0",
"autoprefixer": "^9.8.6",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"babel-plugin-istanbul": "^6.0.0",
"bufferutil": "^4.0.3",
"chai": "^4.3.4",
Expand All @@ -75,15 +80,19 @@
"eslint": "^7.26.0",
"eslint-config-standard": "^16.0.2",
"eslint-config-vuetify": "^0.5.0",
"eslint-import-resolver-node": "^0.3.4",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "^7.9.0",
"graphql-language-service-utils": "^2.5.2",
"istanbul-instrumenter-loader": "^3.0.1",
"istanbul-lib-coverage": "^3.0.0",
"json-server": "^0.16.3",
"markdown-it": "^12.0.6",
"null-loader": "^4.0.1",
"nyc": "^15.1.0",
"postcss": "^8.2.13",
"regenerator-runtime": "^0.13.7",
"sass": "^1.32.12",
"sass-loader": "^10.1.1",
"sinon": "^10.0.0",
Expand All @@ -96,11 +105,11 @@
"vue-cli-plugin-vuetify-essentials": "^0.8.3",
"vue-template-compiler": "^2.6.12",
"vuetify-loader": "^1.7.2",
"webpack": "^4.46.0"
"webpack": "^4.46.0",
"zen-observable": "^0.8.15"
},
"resolutions": {
"cypress": "^7.3.0",
"istanbul-instrumenter-loader/**/istanbul-lib-instrument": "4.0.1"
"cypress": "^7.3.0"
},
"bugs": {
"url": "https://github.com/cylc/cylc-ui/issues"
Expand Down
6 changes: 3 additions & 3 deletions postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

module.exports = {
plugins: {
autoprefixer: {}
}
plugins: [
require('autoprefixer')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yarn failed to build due to the old syntax? 🤷‍♂️ copied this from the autoprefixer docs.

]
}
4 changes: 2 additions & 2 deletions src/components/cylc/tree/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ import TreeItem from '@/components/cylc/tree/TreeItem'
import Vue from 'vue'
import TaskState from '@/model/TaskState.model'
import Task from '@/components/cylc/Task'
import clonedeep from 'lodash.clonedeep'
import cloneDeep from 'lodash/cloneDeep'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first one was using the lodash.clonedeep single dependency, which was a transitive dependency.

Our build failed as Yarn is more strict about the transitive dependencies not declared in our package.json (we had similar issue in Python & setuptools I think? Maybe a trend in build tools? anyhoo).

Instead of simply adding the new dependency, the change here is using importing the cloneDeep module from our already imported lodash dependency. Tree shaking doesn't seem to work too well for Lodash at the moment with our Vue-CLI/Babel/Webpack build chain, but it does with RollUp and with with Vite, which we will probably have a chance to look into when moving to Vue 3.

import { mdiPlus, mdiMinus } from '@mdi/js'

export default {
Expand Down Expand Up @@ -254,7 +254,7 @@ export default {
this.tasksFilter.states !== null &&
this.tasksFilter.states.length > 0
if (taskNameFilterSet || taskStatesFilterSet) {
this.activeFilters = clonedeep(this.tasksFilter)
this.activeFilters = cloneDeep(this.tasksFilter)
this.filterNodes(this.workflows)
} else {
this.removeAllFilters()
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Meta from 'vue-meta'
import NProgress from 'nprogress'
import store from '@/store'

import '../../node_modules/nprogress/css/nprogress.css'
import 'nprogress/css/nprogress.css'

// Routes
import paths from './paths'
Expand Down
2 changes: 1 addition & 1 deletion src/styles/cylc/_tree.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@import '../../../node_modules/vuetify/src/styles/styles';
@import '~vuetify/src/styles/styles';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ~ is the correct way. The other syntax is valid depending on your build tools. And I think ~@ means that it's a file in the current project, while ~ means it's a file in the node_modules folder. This broke with Yarn V3 with PnP mode (plug-and-play, when you have no node_modules folder, but instead each dependency loaded from a cache, from what I understand).


$active-color: #BDD5F7;
/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/aotf.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ export async function mutate (mutation, args, apolloClient) {
}
// command in a different format (e.g. info command)
return [TaskState.SUBMITTED, result]
} catch {
} catch (error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one of the Webpack loaders was not happy about this syntax, even though it was working before. I think a new and more strict rule was added somewhere in some dependency 🤷‍♂️

return _mutateError(mutation.name, 'invalid response', response)
}
}
2 changes: 1 addition & 1 deletion tests/unit/components/cylc/tree/tree.vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { simpleWorkflowTree4Nodes } from './tree.data'
import TaskState from '@/model/TaskState.model'
import TreeItem from '@/components/cylc/tree/TreeItem'
import CylcObjectPlugin from '@/components/cylc/cylcObject/plugin'
import cloneDeep from 'lodash.clonedeep'
import cloneDeep from 'lodash/cloneDeep'

const localVue = createLocalVue()
localVue.prototype.$eventBus = {
Expand Down
22 changes: 14 additions & 8 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ module.exports = {
publicPath: '',
outputDir: 'dist',
indexPath: 'index.html',
transpileDependencies: ['vuetify', 'graphql-language-service-interface', 'graphql-language-service-parser'],
transpileDependencies: [
'graphql-language-service-interface',
'graphql-language-service-parser',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two dependencies broke the build due to the null-coallesce operator. I think that could happen in our current Yarn V1 build too at some point?

'vuetify'
],
runtimeCompiler: true,
productionSourceMap: process.env.NODE_ENV !== 'production',
pluginOptions: {
Expand Down Expand Up @@ -74,13 +78,15 @@ module.exports = {
}

// coverage
config.module.rule('istanbul')
.test(/\.js$/)
.include.add(path.resolve('src')).end()
.use('istanbul-instrumenter-loader')
.loader('istanbul-instrumenter-loader')
.options({ esModules: true })
.before('babel-loader')
if (process.env.coverage === 'true') {
config.module.rule('istanbul')
.test(/\.js$/)
.include.add(path.resolve('src')).end()
.use('istanbul-instrumenter-loader')
.loader('istanbul-instrumenter-loader')
.options({ esModules: true })
.after('cache-loader')
}

// resolve modules in devtool
config.output
Expand Down
Loading