mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
normalize properly the modern config to ensure defaults even on scenarios of partial configs
This commit is contained in:
@@ -97,6 +97,22 @@ function compileWithSwc(source, swcOptions = {}, { inputFilePath, features, arch
|
||||
};
|
||||
});
|
||||
}
|
||||
const DEFAULT_MODERN = {
|
||||
transpiler: true,
|
||||
};
|
||||
|
||||
const normalizeModern = r => Object.fromEntries(
|
||||
Object.entries(DEFAULT_MODERN).map(([k, def]) => [
|
||||
k,
|
||||
r === true
|
||||
? def
|
||||
: r === false || r?.[k] === false
|
||||
? false
|
||||
: typeof r?.[k] === 'object'
|
||||
? { ...r[k] }
|
||||
: def,
|
||||
]),
|
||||
);
|
||||
|
||||
let lastModifiedMeteorConfig;
|
||||
let lastModifiedMeteorConfigTime;
|
||||
@@ -110,6 +126,10 @@ BCp.initializeMeteorAppConfig = function () {
|
||||
if (currentLastModifiedConfigTime !== lastModifiedMeteorConfigTime) {
|
||||
lastModifiedMeteorConfigTime = currentLastModifiedConfigTime;
|
||||
lastModifiedMeteorConfig = getMeteorAppPackageJson()?.meteor;
|
||||
lastModifiedMeteorConfig = {
|
||||
...lastModifiedMeteorConfig,
|
||||
modern: normalizeModern(lastModifiedMeteorConfig?.modern),
|
||||
};
|
||||
|
||||
if (lastModifiedMeteorConfig?.modern?.transpiler?.verbose) {
|
||||
logConfigBlock('Meteor Config', lastModifiedMeteorConfig);
|
||||
|
||||
@@ -261,6 +261,25 @@ export function parseRunTargets(targets) {
|
||||
});
|
||||
};
|
||||
|
||||
const DEFAULT_MODERN = {
|
||||
transpiler: true,
|
||||
webArchsOnly: true,
|
||||
watcher: true,
|
||||
};
|
||||
|
||||
const normalizeModern = r => Object.fromEntries(
|
||||
Object.entries(DEFAULT_MODERN).map(([k, def]) => [
|
||||
k,
|
||||
r === true
|
||||
? def
|
||||
: r === false || r?.[k] === false
|
||||
? false
|
||||
: typeof r?.[k] === 'object'
|
||||
? { ...r[k] }
|
||||
: def,
|
||||
]),
|
||||
);
|
||||
|
||||
function isModernArchsOnlyEnabled(appDir) {
|
||||
const packageJsonPath = files.pathJoin(appDir, 'package.json');
|
||||
if (!files.exists(packageJsonPath)) {
|
||||
@@ -268,7 +287,7 @@ function isModernArchsOnlyEnabled(appDir) {
|
||||
}
|
||||
const packageJsonFile = files.readFile(packageJsonPath, 'utf8');
|
||||
const packageJson = JSON.parse(packageJsonFile);
|
||||
return packageJson?.meteor?.modern?.webArchsOnly === true || packageJson?.meteor?.modern === true;
|
||||
return normalizeModern(packageJson?.meteor?.modern).webArchOnly === true;
|
||||
}
|
||||
|
||||
function filterWebArchs(webArchs, excludeArchsOption, appDir, options) {
|
||||
@@ -292,7 +311,7 @@ function filterWebArchs(webArchs, excludeArchsOption, appDir, options) {
|
||||
const hasExcludeArchsOptions = (excludeArchsOptions?.length || 0) > 0;
|
||||
const hasModernArchsOnlyEnabled = appDir && isModernArchsOnlyEnabled(appDir);
|
||||
if (hasExcludeArchsOptions && hasModernArchsOnlyEnabled) {
|
||||
console.warn('modernWebArchsOnly and --exclude-archs are both active. If both are set, --exclude-archs takes priority.');
|
||||
console.warn('modern.webArchsOnly and --exclude-archs are both active. If both are set, --exclude-archs takes priority.');
|
||||
}
|
||||
const automaticallyIgnoredLegacyArchs = (!hasExcludeArchsOptions && hasModernArchsOnlyEnabled) ? ['web.browser.legacy', 'web.cordova'] : [];
|
||||
if (hasExcludeArchsOptions || automaticallyIgnoredLegacyArchs.length) {
|
||||
|
||||
Reference in New Issue
Block a user