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

17165 Migrated from Vue CLI to Vite #524

Merged
merged 8 commits into from
Aug 21, 2023

Conversation

JazzarKarim
Copy link
Collaborator

Issue #: /bcgov/entity#17165

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the bcrs-entities-create-ui license (Apache 2.0).

@JazzarKarim JazzarKarim self-assigned this Aug 16, 2023
@JazzarKarim
Copy link
Collaborator Author

/gcbrun

@pwei1018
Copy link
Collaborator

Temporary Url for review: https://business-edit-dev--pr-524-sru298p2.web.app

@bcgov bcgov deleted a comment from pwei1018 Aug 17, 2023
@bcgov bcgov deleted a comment from pwei1018 Aug 17, 2023
@@ -20,7 +20,7 @@
{ "key" : "X-XSS-Protection", "value" : "1; mode=block" },
{
"key": "Content-Security-Policy",
"value": "default-src 'self'; frame-src 'self' *.gov.bc.ca *.hotjar.com *.googleapis.com https://*.nr-data.net https://*.newrelic.com https://*.cac1.pure.cloud; script-src 'self' 'unsafe-eval' 'unsafe-inline' *.gov.bc.ca *.hotjar.com *.googleapis.com https://*.nr-data.net https://*.newrelic.com https://*.cac1.pure.cloud; style-src 'self' 'unsafe-inline' *.cloudflare.com *.googleapis.com; font-src 'self' *.gov.bc.ca *.hotjar.com *.cloudflare.com *.googleapis.com *.gstatic.com *.jsdelivr.net; img-src 'self' data: *.hotjar.com https://*.cac1.pure.cloud; connect-src 'self' *.gov.bc.ca *.launchdarkly.com *.hotjar.com *.postescanada-canadapost.ca *.sentry.io *.apigee.net wss://*.hotjar.com *.hotjar.io https://*.nr-data.net https://shyrka-prod-cac1.s3.ca-central-1.amazonaws.com https://*.newrelic.com https://*.cac1.pure.cloud wss://*.cac1.pure.cloud; manifest-src 'self'; media-src 'self' https://*.cac1.pure.cloud; object-src 'self' https://*.cac1.pure.cloud; child-src 'self' https://*.cac1.pure.cloud;"
"value": "default-src 'self'; frame-src 'self' *.gov.bc.ca *.hotjar.com *.googleapis.com https://*.nr-data.net https://*.newrelic.com https://*.cac1.pure.cloud; script-src 'self' 'unsafe-eval' 'unsafe-inline' *.gov.bc.ca *.hotjar.com *.googleapis.com https://*.nr-data.net https://*.newrelic.com https://*.cac1.pure.cloud; style-src 'self' 'unsafe-inline' *.cloudflare.com *.googleapis.com; font-src 'self' *.gov.bc.ca *.hotjar.com *.cloudflare.com *.googleapis.com *.gstatic.com *.jsdelivr.net; img-src 'self' *.postescanada-canadapost.ca https://*.cac1.pure.cloud data: *.hotjar.com https://*.cac1.pure.cloud; connect-src 'self' *.gov.bc.ca *.launchdarkly.com *.hotjar.com *.postescanada-canadapost.ca *.sentry.io *.apigee.net wss://*.hotjar.com *.hotjar.io https://*.nr-data.net https://shyrka-prod-cac1.s3.ca-central-1.amazonaws.com https://*.newrelic.com https://*.cac1.pure.cloud wss://*.cac1.pure.cloud; manifest-src 'self'; media-src 'self' https://*.cac1.pure.cloud; object-src 'self' https://*.cac1.pure.cloud; child-src 'self' https://*.cac1.pure.cloud;"
Copy link
Collaborator Author

@JazzarKarim JazzarKarim Aug 17, 2023

Choose a reason for hiding this comment

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

Fixing the Canada post icon:
canada post img error

The same change has been done in the nginx.conf file.

It works now:
Screenshot (87)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this have to be fixed in Create UI also? I only see 1 ref to CanadaPost in Create UI but 2 here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No Sev. It already works fine in Create UI. In nginx.conf, there should be 2 references for it. I went ahead and made the line similar in firebase.json because they should be similar.

In Create UI, it's the same as here in nginx.conf now but it's little bit different in firebase.json like you mentioned as there's only one ref there. In my opinion, we should change in Create UI so that the CSP is similar in both files. However, this change won't affect any functionalities. It's just to stay consistent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, thanks. I have no further comment on this.

},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
// Fix inline dependency of a dependency, which is the case in Tiptap-Vuetify
mainFields: ['module']
Copy link
Collaborator Author

@JazzarKarim JazzarKarim Aug 17, 2023

Choose a reason for hiding this comment

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

Tiptap Vuetify wasn't letting my tests to run:
test error

This is to fix that.

"@bcrs-shared-components/court-order-poa": "2.1.3",
"@bcrs-shared-components/date-picker": "1.2.5",
"@bcrs-shared-components/detail-comment": "1.1.1",
"@bcrs-shared-components/enums": "1.0.45",
"@bcrs-shared-components/detail-comment": "1.1.3",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updating detail comment component to fix lodash issue.

esbuildOptions: {
// Fix Module has been externalized for browser compatibility warning.
plugins: [
NodeModulesPolyfillPlugin()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There was a warning in the console ONLY when running locally:
only in local

This fixes all of them except for source-map-js warning. When running locally now:
source-map-js

@JazzarKarim
Copy link
Collaborator Author

/gcbrun

@pwei1018
Copy link
Collaborator

Temporary Url for review: https://business-edit-dev--pr-524-sru298p2.web.app

"test:debug": "node --inspect-brk node_modules/.bin/vue-cli-service test:unit --testPathPattern --no-cache --watch --runInBand"
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
Copy link
Collaborator

@seeker25 seeker25 Aug 17, 2023

Choose a reason for hiding this comment

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

port 8080? maybe not call it serve (otherwise someone on autopilot will be like why isn't my code changing like before? )
I called it preview

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes a lot sense. I was just following the official guide in this and the other PR: https://vueschool.io/articles/vuejs-tutorials/how-to-migrate-from-vue-cli-to-vite/
migration guide

In the guide, they mention that npm run serve is vite preview.

I do agree with you though Travis.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I was bitten by this last week. I have to condition myself to type "npm run dev" now, that's all.

I like that Karim is following the official guide.

package.json Outdated
"vue-hotjar": "^1.4.0",
"vue-router": "^3.6.5",
"vue-the-mask": "^0.11.1",
"vue2-filters": "^0.14.0",
"vuelidate": "^0.7.7",
"vuelidate": "0.6.2",
"vuetify": "^2.6.15",
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably don't need this babel line

@@ -24,6 +24,7 @@ import mockRouter from './MockRouter'
import { createPinia, setActivePinia } from 'pinia'
import { useStore } from '@/store/store'
import { CorpTypeCd, FilingTypes } from '@/enums'
import { vi } from 'vitest'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there's a way to include vi without needing to explicitly include it in the test? don't know how though

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can achieve that by using vitest.xxx and in this case, no need to import vi. Shall I make this change Travis?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I let this one past when you did Create UI -- I don't care, either way.

expect(labels.at(1).text()).toBe('Mailing Address Corrected')
expect(labels.at(2).text()).toBe('Delivery Address Corrected')
expect(labels.at(1).text()).toContain('Mailing Address')
expect(labels.at(1).text()).toContain('Corrected')
Copy link
Collaborator

@seeker25 seeker25 Aug 17, 2023

Choose a reason for hiding this comment

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

I've seen some funky stuff happen calling this twice

Copy link
Collaborator

Choose a reason for hiding this comment

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

Really? Should work.

const sbcVersion = JSON.parse(packageJson).dependencies['sbc-common-components']
const aboutText1 = (appName && appVersion) ? `${appName} v${appVersion}` : ''
const aboutText2 = (sbcName && sbcVersion) ? `${sbcName} v${sbcVersion}` : ''

module.exports = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove vue.config.js?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Project runs but getting a fatal error when I run unit tests:
fatal error unit tests

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file looks the same as in Create UI so I'm OK with this.

Copy link
Collaborator

@severinbeauvais severinbeauvais left a comment

Choose a reason for hiding this comment

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

LGTM other than a few small comments.

@JazzarKarim JazzarKarim force-pushed the 17165-upgrade-to-vite branch from bdb7876 to e411b68 Compare August 21, 2023 17:49
@JazzarKarim
Copy link
Collaborator Author

/gcbrun

@pwei1018
Copy link
Collaborator

Temporary Url for review: https://business-edit-dev--pr-524-sru298p2.web.app

@JazzarKarim
Copy link
Collaborator Author

/gcbrun

@pwei1018
Copy link
Collaborator

Temporary Url for review: https://business-edit-dev--pr-524-sru298p2.web.app

@JazzarKarim JazzarKarim merged commit 156b3e4 into bcgov:main Aug 21, 2023
@severinbeauvais severinbeauvais changed the title Migrated from Vue CLI to Vite 17165 Migrated from Vue CLI to Vite Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants