mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge branch 'modern-bundler-integration' into release-3.4
This commit is contained in:
@@ -36,6 +36,7 @@ export const GLOBAL_STATE_KEYS = {
|
||||
RSPACK_REACT_INSTALLATION_CHECKED: 'rspack.rspackReactInstallationChecked',
|
||||
RSPACK_DOCTOR_INSTALLATION_CHECKED: 'rspack.rspackDoctorInstallationChecked',
|
||||
REACT_CHECKED: 'rspack.reactChecked',
|
||||
TYPESCRIPT_CHECKED: 'rspack.typescriptChecked',
|
||||
INITIAL_ENTRYPONTS: 'meteor.initialEntrypoints',
|
||||
CLIENT_FIRST_COMPILE: 'rspack.clientFirstCompile',
|
||||
SERVER_FIRST_COMPILE: 'rspack.serverFirstCompile',
|
||||
|
||||
@@ -211,3 +211,31 @@ export async function ensureRspackDoctorInstalled() {
|
||||
'Rspack Doctor'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if TypeScript is installed and sets global state accordingly
|
||||
* Sets global state and environment variables based on TypeScript detection
|
||||
* @returns {boolean} Whether TypeScript is installed
|
||||
*/
|
||||
export function checkTypescriptInstalled() {
|
||||
// Skip if already checked
|
||||
if (getGlobalState(GLOBAL_STATE_KEYS.TYPESCRIPT_CHECKED, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const appDir = getMeteorAppDir();
|
||||
// Check if TypeScript is a dependency in the project
|
||||
const isTypescriptInstalled = checkNpmDependencyExists('typescript', { cwd: appDir });
|
||||
|
||||
if (isTypescriptInstalled) {
|
||||
// Set environment variable to indicate TypeScript is enabled
|
||||
process.env.METEOR_TYPESCRIPT_ENABLED = 'true';
|
||||
} else {
|
||||
process.env.METEOR_TYPESCRIPT_ENABLED = 'false';
|
||||
}
|
||||
|
||||
// Mark as checked
|
||||
setGlobalState(GLOBAL_STATE_KEYS.TYPESCRIPT_CHECKED, true);
|
||||
|
||||
return isTypescriptInstalled;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @description Functions for managing Rspack processes
|
||||
*/
|
||||
import { checkNpmDependencyExists, getNpxCommand } from 'meteor/tools-core/lib/npm';
|
||||
import { getMeteorAppPort } from 'meteor/tools-core/lib/meteor';
|
||||
import { getMeteorAppPort, isMeteorTypescriptProject } from 'meteor/tools-core/lib/meteor';
|
||||
|
||||
/**
|
||||
* Calculates the devServerPort based on process.env.PORT
|
||||
@@ -136,11 +136,14 @@ export function getRspackEnv({ isClient, isServer, isTest: inIsTest }) {
|
||||
|
||||
const entryKey = `${isTest && isTestModule ? 'test' : 'main'}${isClient ? 'Client' : 'Server'}`;
|
||||
const inputFilePath = isTest && isTestModule ? initialEntrypoints.testModule : initialEntrypoints[entryKey];
|
||||
const isTypescriptEnabled = inputFilePath?.endsWith('.ts') || inputFilePath?.endsWith('.tsx');
|
||||
const isTsxEnabled = inputFilePath?.endsWith('.tsx');
|
||||
const isJsxEnabled = inputFilePath?.endsWith('.jsx');
|
||||
const isTypescriptEnabled = process.env.METEOR_TYPESCRIPT_ENABLED === 'true' ||
|
||||
inputFilePath?.endsWith('.ts') ||
|
||||
inputFilePath?.endsWith('.tsx');
|
||||
|
||||
const isReactEnabled = process.env.METEOR_REACT_ENABLED === 'true';
|
||||
const isTsxEnabled = isTypescriptEnabled && (inputFilePath?.endsWith('.tsx') || isReactEnabled);
|
||||
const isJsxEnabled = !isTypescriptEnabled && (inputFilePath?.endsWith('.jsx') || isReactEnabled);
|
||||
|
||||
const isReactEnabled = !!process.env.METEOR_REACT_ENABLED;
|
||||
const isBlazeEnabled = isMeteorBlazeProject();
|
||||
const isBlazeHotEnabled = isMeteorBlazeHotProject();
|
||||
const isBundleVisualizerEnabled = isMeteorBundleVisualizerProject();
|
||||
|
||||
@@ -22,6 +22,7 @@ const {
|
||||
const {
|
||||
ensureRspackInstalled,
|
||||
checkReactInstalled,
|
||||
checkTypescriptInstalled,
|
||||
ensureRspackReactInstalled,
|
||||
} = require('./lib/dependencies');
|
||||
|
||||
@@ -114,13 +115,19 @@ if (isMeteorAppRun() || isMeteorAppBuild() || isMeteorAppTest()) {
|
||||
if (hasMeteorAppConfigAutoInstallDeps()) {
|
||||
// Ensure Rspack is installed
|
||||
await ensureRspackInstalled();
|
||||
}
|
||||
|
||||
// Check if Rspack React is installed
|
||||
if (checkReactInstalled()) {
|
||||
// Check if Rspack React is installed
|
||||
if (checkReactInstalled()) {
|
||||
// Auto install deps (by default enabled)
|
||||
if (hasMeteorAppConfigAutoInstallDeps()) {
|
||||
await ensureRspackReactInstalled();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if TypeScript is installed
|
||||
checkTypescriptInstalled();
|
||||
|
||||
// Ensure the Rspack build context directory exists
|
||||
ensureRspackBuildContextExists();
|
||||
|
||||
|
||||
@@ -421,6 +421,14 @@ export function isMeteorBundleVisualizerProject() {
|
||||
return getMeteorAppPackages().includes('bundle-visualizer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the Meteor application is a Typescript project.
|
||||
* @returns {boolean} True if the application is a Typescript project, false otherwise.
|
||||
*/
|
||||
export function isMeteorTypescriptProject() {
|
||||
return getMeteorAppPackages().includes('typescript');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current Meteor command is 'test-packages'.
|
||||
* @returns {boolean} True if the current command is 'test-packages', false otherwise.
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
"babel-loader": "^9.1.3",
|
||||
"less": "^4.4.0",
|
||||
"less-loader": "^12.3.0",
|
||||
"playwright": "^1.54.2"
|
||||
"playwright": "^1.54.2",
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"meteor": {
|
||||
"mainModule": {
|
||||
|
||||
@@ -5,8 +5,10 @@ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/
|
||||
import '@helper/alias';
|
||||
import ReactAlias from '@react/alias';
|
||||
import './resolve-extensions/first';
|
||||
import { TypescriptEnabled } from './ts/helpers';
|
||||
|
||||
console.log('@react/alias loaded', ReactAlias.version);
|
||||
console.log('TypescriptEnabled', TypescriptEnabled);
|
||||
|
||||
async function insertLink({ title, url }) {
|
||||
await LinksCollection.insertAsync({ title, url, createdAt: new Date() });
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const TypescriptEnabled: boolean = true;
|
||||
@@ -167,7 +167,6 @@ export async function assertConsoleEval(code, expectedResult, options = {}) {
|
||||
try {
|
||||
// Evaluate the code in the browser context
|
||||
const result = await page.evaluate(code);
|
||||
console.log("--> (assertions.js-Line: 170)\n result: ", result);
|
||||
|
||||
if (exactMatch) {
|
||||
// Check for exact match
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('ReactRouter App Bundling /', () => {
|
||||
},
|
||||
customAssertions: {
|
||||
afterRun: async ({ result, port }) => {
|
||||
await waitForReactEnvs(result.outputLines, { isJsxEnabled: true });
|
||||
await waitForReactEnvs(result.outputLines, { isTsxEnabled: true });
|
||||
await waitForMeteorOutput(result.outputLines, /.*babel-plugin-react-compiler.*/);
|
||||
await assert404Page(port);
|
||||
// Less styles support
|
||||
@@ -47,7 +47,7 @@ describe('ReactRouter App Bundling /', () => {
|
||||
await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/);
|
||||
},
|
||||
afterRunProduction: async ({ result, port }) => {
|
||||
await waitForReactEnvs(result.outputLines, { isJsxEnabled: true });
|
||||
await waitForReactEnvs(result.outputLines, { isTsxEnabled: true });
|
||||
await waitForMeteorOutput(result.outputLines, /.*babel-plugin-react-compiler.*/);
|
||||
await assert404Page(port, { isProductionMode: true });
|
||||
// Less styles support
|
||||
@@ -74,7 +74,7 @@ describe('ReactRouter App Bundling /', () => {
|
||||
await waitForReactEnvs(result.outputLines);
|
||||
},
|
||||
afterBuild: async ({ result }) => {
|
||||
await waitForReactEnvs(result.outputLines, { isJsxEnabled: true });
|
||||
await waitForReactEnvs(result.outputLines, { isTsxEnabled: true });
|
||||
await waitForMeteorOutput(result.outputLines, /.*babel-plugin-react-compiler.*/);
|
||||
},
|
||||
}
|
||||
@@ -95,10 +95,10 @@ export async function waitForReactEnvs(outputLines, options = {}) {
|
||||
/.*isReactEnabled:.*true.*/,
|
||||
options
|
||||
);
|
||||
if (options.isJsxEnabled) {
|
||||
if (options.isTsxEnabled) {
|
||||
await waitForMeteorOutput(
|
||||
outputLines,
|
||||
/.*isJsxEnabled:.*true.*/,
|
||||
/.*isTsxEnabled:.*true.*/,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user