Skip to content

Commit

Permalink
fix(quasar-cli-vue3): fixed prod builds (#3208)
Browse files Browse the repository at this point in the history
* fix(quasar-cli-vue3): fixed prod builds

* fix(quasar-cli-vue3): fixed prod builds

* fix(quasar-cli-vue3-webpack-javascript): updated general README

* fix(quasar-cli-vue3-webpack-javascript): updated READMEs

* fix(quasar-cli-vue3-webpack-javascript): updated READMEs
  • Loading branch information
lexasq authored Nov 1, 2023
1 parent 5450ecf commit 067477a
Show file tree
Hide file tree
Showing 42 changed files with 1,040 additions and 0 deletions.
74 changes: 74 additions & 0 deletions quasar-cli-vue3-webpack-javascript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Quasar cli with Javascript

app-exposes: quasar project which exposes components

app-general: quasar project which consume those components

## Working
### Step 1
Run app-exposes project first runs on 3001
```bash
cd app-exposes
yarn
yarn setup-env:dev
quasar dev
```
### Step 2
Then run app-general project on 3002
```bash
cd app-general
yarn
yarn setup-env:dev
quasar dev
```
Note: You may change the port number as you wish but make sure the address is correct while adding a remote.

## Explanation

To setup module federation in a quasar project. We need to do 3 things

### Step 1

To solve [Eager consumption error](https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption)
```javascript
// In '.quasar' directory, create 'main.js' file and add this line
import('./client-entry');
// client-entry.js file is the default entry point in quasar project and we are invoking it from main.js now
```
and set the new entry point to `main.js` from `quasar.config.js`
```javascript
// in 'quasar.config.js'
extendWebpack(cfg){
cfg.entry = path.resolve(__dirname, './.quasar/main.js')
}
```
This way we are bootstrapping the application.

### Step 2
Add this link in `quasar.config.js` inside `chainWebpack` function
```javascript
chainWebpack (chain) {
// ...
chain.optimization.delete('splitChunks');
}
```

### Step 3
Import the `ModuleFederationPlugin` and initialise inside `extendWebpack`
```javascript
extendWebpack(cfg) {
cfg.entry = path.resolve(__dirname, './.quasar/main.js') // from step 1
cfg.plugins.push(
new ModuleFederationPlugin({
name: 'app_remote',
filename: 'remoteEntry.js',
exposes: {},
remotes: {},
shared: {
...dependencies,
}
}),
);
},
```
Now you can start using the plugin!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"folders":["C:\\Users\\shark\\OneDrive\\Desktop\\module-federation-examples\\quasar-cli-vue3-webpack-javascript\\exposes\\dist\\spa","C:\\Users\\shark\\OneDrive\\Desktop\\module-federation-examples\\quasar-cli-vue3-webpack-javascript\\app-exposes\\dist\\spa","C:\\Users\\shark\\OneDrive\\Desktop\\module-federation-examples\\quasar-cli-vue3-webpack-javascript\\app-exposes\\dist\\pwa"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* THIS FILE IS GENERATED AUTOMATICALLY.
* DO NOT EDIT.
*
* You are probably looking on adding startup/initialization code.
* Use "quasar new boot <name>" and add it there.
* One boot file per concern. Then reference the file(s) in quasar.config.js > boot:
* boot: ['file', ...] // do not add ".js" extension to it.
*
* Boot files are your "main.js"
**/


import { createApp } from 'vue'







import '@quasar/extras/roboto-font/roboto-font.css'

import '@quasar/extras/material-icons/material-icons.css'




// We load Quasar stylesheet file
import 'quasar/dist/quasar.sass'




import 'src/css/app.scss'


import createQuasarApp from './app.js'
import quasarUserOptions from './quasar-user-options.js'






console.info('[Quasar] Running SPA.')





const publicPath = `http://localhost:3001/`

const doubleSlashRE = /\/\//
const addPublicPath = url => (publicPath + url).replace(doubleSlashRE, '/')


async function start ({
app,
router

}) {




app.use(router)







app.mount('#q-app')






}

createQuasarApp(createApp, quasarUserOptions)

.then(start)

45 changes: 45 additions & 0 deletions quasar-cli-vue3-webpack-javascript/app-exposes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Quasar App (app-exposes)

A Quasar Project

## Install the dependencies
```bash
yarn
# or
npm install
```

### Start the app in development mode (hot-code reloading, error reporting, etc.)
```bash
yarn setup-env:dev
quasar dev
```


### Lint the files
```bash
yarn lint
# or
npm run lint
```


### Format the files
```bash
yarn format
# or
npm run format
```



### Build the app for production
```bash
yarn setup-env:prod
quasar build
cd dist/spa
quasar serve -p 3001
```

### Customize the configuration
See [Configuring quasar.config.js](https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"publicPath": "/"
}
3 changes: 3 additions & 0 deletions quasar-cli-vue3-webpack-javascript/app-exposes/envs/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"publicPath": "http://localhost:3001/"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"publicPath": "http://localhost:3001/"
}
49 changes: 49 additions & 0 deletions quasar-cli-vue3-webpack-javascript/app-exposes/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "app-exposes",
"version": "0.0.1",
"description": "A Quasar Project",
"productName": "Quasar App",
"author": "kama7 <[email protected]>",
"private": true,
"scripts": {
"lint": "eslint --ext .js,.vue ./",
"format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"No test specified\" && exit 0",
"setup-env:dev": "shx cp -r envs/env.dev.json envs/env.json",
"setup-env:prod": "shx cp -r envs/env.prod.json envs/env.json"
},
"dependencies": {
"@quasar/extras": "^1.0.0",
"core-js": "^3.6.5",
"quasar": "^2.6.0",
"vue": "^3.0.0",
"shx": "0.3.3",
"vue-router": "^4.0.0"
},
"devDependencies": {
"@babel/eslint-parser": "7.21.3",
"@quasar/app-webpack": "3.7.2",
"eslint": "8.26.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-vue": "9.6.0",
"eslint-webpack-plugin": "3.2.0",
"prettier": "2.8.8",
"workbox-webpack-plugin": "^6.0.0"
},
"browserslist": [
"last 10 Chrome versions",
"last 10 Firefox versions",
"last 4 Edge versions",
"last 7 Safari versions",
"last 8 Android versions",
"last 8 ChromeAndroid versions",
"last 8 FirefoxAndroid versions",
"last 10 iOS versions",
"last 5 Opera versions"
],
"engines": {
"node": ">= 12.22.1",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

5 comments on commit 067477a

@vercel
Copy link

@vercel vercel bot commented on 067477a Nov 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

medusa-example-nav – ./medusa-example/nav

medusa-example-nav-git-master-module-federation.vercel.app
medusa-example-nav-module-federation.vercel.app
medusa-example-nav.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 067477a Nov 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

medusa-example-home – ./medusa-example/home

medusa-example-home-git-master-module-federation.vercel.app
medusa-example-home.vercel.app
medusa-example-home-module-federation.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 067477a Nov 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

medusa-example-utils – ./medusa-example/utils

medusa-example-utils-git-master-module-federation.vercel.app
medusa-example-utils-module-federation.vercel.app
medusa-example-utils.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 067477a Nov 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

medusa-example-search – ./medusa-example/search

medusa-example-search.vercel.app
medusa-example-search-git-master-module-federation.vercel.app
medusa-example-search-module-federation.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 067477a Nov 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

medusa-example-dsl – ./medusa-example/dsl

medusa-example-dsl-git-master-module-federation.vercel.app
medusa-example-dsl.vercel.app
medusa-example-dsl-module-federation.vercel.app

Please sign in to comment.