Skip to content

Commit 6a3c4ac

Browse files
fix(app-vite&app-webpack): improve pnpm monorepo support for capacitor (#18218)
* feat(app-vite): improve pnpm monorepo support for capacitor * feat(app-webpack): improve pnpm monorepo support for capacitor * refactor(app-vite): utilize jsdoc types in more places * refactor(app-webpack): utilize jsdoc types in more places * chore: add electron-winstaller to pnpm onlyBuiltDependencies list * refactor(app-vite): further clarify pnpm support regarding workspaces * refactor(app-webpack): further clarify pnpm support regarding workspaces
1 parent 4ebebf0 commit 6a3c4ac

File tree

25 files changed

+240
-1
lines changed

25 files changed

+240
-1
lines changed

app-vite/lib/cache/create-cache-proxy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @param {import('../../types/configuration/context').InternalQuasarContext} ctx
3+
*
4+
* @returns {import('../../types/configuration/context').CacheProxy}
5+
*/
16
export function createCacheProxy (ctx) {
27
const runtimeCache = {}
38
const moduleCache = {}

app-vite/lib/modes/bex/bex-installation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import fse from 'fs-extra'
33
import { log, warn } from '../../utils/logger.js'
44
import { isModeInstalled } from '../modes-utils.js'
55

6+
/**
7+
* @param {{
8+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
9+
* silent: boolean
10+
* }} options
11+
*/
612
export async function addMode ({
713
ctx: { appPaths, cacheProxy },
814
silent
@@ -26,6 +32,11 @@ export async function addMode ({
2632
log('Browser Extension support was added')
2733
}
2834

35+
/**
36+
* @param {{
37+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
38+
* }} options
39+
*/
2940
export function removeMode ({
3041
ctx: { appPaths }
3142
}) {

app-vite/lib/modes/capacitor/capacitor-installation.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import { spawnSync } from '../../utils/spawn.js'
99
import { ensureDeps, ensureConsistency } from './ensure-consistency.js'
1010
import { isModeInstalled } from '../modes-utils.js'
1111

12+
/**
13+
* @param {{
14+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
15+
* silent: boolean,
16+
* target: 'android' | 'ios' | undefined
17+
* }} options
18+
*/
1219
export async function addMode ({
1320
ctx: { appPaths, cacheProxy, pkg: { appPkg } },
1421
silent,
@@ -60,6 +67,10 @@ export async function addMode ({
6067
globSync([ '**/*' ], {
6168
cwd: appPaths.resolve.cli('templates/capacitor')
6269
}).forEach(filePath => {
70+
if (filePath.endsWith('pnpm-workspace.yaml') && nodePackager.name !== 'pnpm') {
71+
return
72+
}
73+
6374
const dest = appPaths.resolve.capacitor(filePath)
6475
const content = fse.readFileSync(appPaths.resolve.cli('templates/capacitor/' + filePath))
6576
fse.ensureFileSync(dest)
@@ -94,6 +105,11 @@ export async function addMode ({
94105
await addPlatform(target, appPaths, cacheProxy)
95106
}
96107

108+
/**
109+
* @param {{
110+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
111+
* }} options
112+
*/
97113
export function removeMode ({
98114
ctx: { appPaths }
99115
}) {

app-vite/lib/modes/capacitor/ensure-consistency.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export async function ensureDeps ({ appPaths, cacheProxy }) {
2121
nodePackager.install({
2222
cwd: appPaths.capacitorDir,
2323
// See https://github.com/orgs/pnpm/discussions/4735
24+
// We also started creating an empty pnpm-workspace.yaml file in src-capacitor as of app-vite v2.4.1
25+
// which addresses all cases without requiring explicit ignore-workspace flag all the time.
26+
// However, we are keeping this for backward compatibility of the scaffolded projects and just in case.
2427
params: nodePackager.name === 'pnpm' ? [ 'i', '--ignore-workspace' ] : undefined,
2528
displayName: 'Capacitor'
2629
})

app-vite/lib/modes/cordova/cordova-installation.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import { spawnSync } from '../../utils/spawn.js'
66
import { ensureWWW, ensureConsistency } from './ensure-consistency.js'
77
import { isModeInstalled } from '../modes-utils.js'
88

9+
/**
10+
* @param {{
11+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
12+
* silent: boolean,
13+
* target: 'android' | 'ios' | undefined
14+
* }} options
15+
*/
916
export async function addMode ({
1017
ctx: { appPaths, pkg: { appPkg } },
1118
silent,
@@ -76,6 +83,11 @@ export async function addMode ({
7683
addPlatform(appPaths, target)
7784
}
7885

86+
/**
87+
* @param {{
88+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
89+
* }} options
90+
*/
7991
export function removeMode ({
8092
ctx: { appPaths }
8193
}) {

app-vite/lib/modes/electron/electron-installation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const electronDeps = {
77
electron: 'latest'
88
}
99

10+
/**
11+
* @param {{
12+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
13+
* silent: boolean
14+
* }} options
15+
*/
1016
export async function addMode ({
1117
ctx: { appPaths, cacheProxy },
1218
silent
@@ -41,6 +47,11 @@ export async function addMode ({
4147
log('Electron support was added')
4248
}
4349

50+
/**
51+
* @param {{
52+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
53+
* }} options
54+
*/
4455
export async function removeMode ({
4556
ctx: { appPaths, cacheProxy }
4657
}) {

app-vite/lib/modes/pwa/pwa-installation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const pwaDeps = {
1919
'register-service-worker': '^1.7.2'
2020
}
2121

22+
/**
23+
* @param {{
24+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
25+
* silent: boolean
26+
* }} options
27+
*/
2228
export async function addMode ({
2329
ctx: { appPaths, cacheProxy },
2430
silent
@@ -63,6 +69,11 @@ export async function addMode ({
6369
log('PWA support was added')
6470
}
6571

72+
/**
73+
* @param {{
74+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
75+
* }} options
76+
*/
6677
export async function removeMode ({
6778
ctx: { appPaths, cacheProxy }
6879
}) {

app-vite/lib/modes/ssr/ssr-installation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import fse from 'fs-extra'
33
import { log, warn } from '../../utils/logger.js'
44
import { isModeInstalled } from '../modes-utils.js'
55

6+
/**
7+
* @param {{
8+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
9+
* silent: boolean
10+
* }} options
11+
*/
612
export async function addMode ({
713
ctx: { appPaths, cacheProxy },
814
silent
@@ -25,6 +31,11 @@ export async function addMode ({
2531
log('SSR support was added')
2632
}
2733

34+
/**
35+
* @param {{
36+
* ctx: import('../../../types/configuration/context').InternalQuasarContext,
37+
* }} options
38+
*/
2839
export function removeMode ({
2940
ctx: { appPaths }
3041
}) {

app-vite/lib/utils/get-ctx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function defineHiddenProp (target, propName, value) {
1313
}
1414

1515
/**
16-
* @returns {import('../../types/configuration/context').QuasarContext}
16+
* @returns {import('../../types/configuration/context').InternalQuasarContext}
1717
*/
1818
export function getCtx (opts = {}) {
1919
const ctx = {

app-vite/lib/utils/get-pkg.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { parseJSON } from 'confbox'
44
import { warning } from './logger.js'
55
import { getPackageJson } from '../utils/get-package-json.js'
66

7+
/**
8+
* @param {import('../../types/app-paths').QuasarAppPaths} appPaths
9+
*
10+
* @returns {import('../../types/configuration/context').InternalQuasarContext['pkg']}
11+
*/
712
export function getPkg (appPaths) {
813
const { appDir, cliDir } = appPaths
914
const appPkgPath = appPaths.resolve.app('package.json')

0 commit comments

Comments
 (0)