meteor-modern-build-stack
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseModern build stack
现代构建栈
The modern build stack is two independent tracks. Enable either or both.
- Meteor Bundler Optimizations (Meteor 3.3+). One flag, SWC replaces
Babel, SWC minifier replaces Terser, replaces the legacy watcher, development skips legacy archs.
@parcel/watcher - Rspack Bundler Integration (Meteor 3.4+). Atmosphere package delegates app-code compilation to Rspack. Tree shaking, ESM, code splitting via HTTP, modern bundler plugins.
Standard current application skeletons ship both enabled.
Purposefully small or compatibility-oriented skeletons, including
and , may omit Rspack or the modern flag. Inspect the generated
and instead of inferring features only from
the Meteor version. For existing apps, enable optimizations first, then add
Rspack once the app code is standards-clean.
meteor createminimallegacypackage.json.meteor/packages现代构建栈包含两条独立的路径,可启用其中一条或同时启用两条。
- Meteor打包器优化(Meteor 3.3及以上版本):只需一个配置项,SWC将替代Babel,SWC压缩器替代Terser,替代旧版监视器,开发环境将跳过旧版架构。
@parcel/watcher - Rspack打包器集成(Meteor 3.4及以上版本):通过Atmosphere包将应用代码编译委托给Rspack,支持摇树优化、ESM、基于HTTP的代码分割以及现代打包器插件。
当前标准的应用骨架默认同时启用这两项功能。专为小型项目或兼容性设计的骨架(包括和)可能会省略Rspack或现代配置项。请查看生成的和文件,而不要仅根据Meteor版本推断功能。对于现有应用,请先启用优化功能,待应用代码符合标准规范后再添加Rspack。
meteor createminimallegacypackage.json.meteor/packagesEnable Meteor Bundler Optimizations
启用Meteor打包器优化
Add to :
package.jsonjson
"meteor": {
"modern": true
}This enables SWC, the SWC minifier, the modern watcher, and dev-mode web
arch skipping. Each falls back to legacy when something is incompatible, so
this is backward compatible.
Opt out of pieces:
json
"meteor": {
"modern": {
"transpiler": false,
"minifier": false,
"watcher": false,
"webArchOnly": false
}
}Or scope SWC: , ,
, . Accept or
an array of paths/regexes.
transpiler.excludeApptranspiler.excludeNodeModulestranspiler.excludePackagestranspiler.excludeLegacytrueVerbose transpiler logs to diagnose Babel fallbacks:
json
"meteor": {
"modern": {
"transpiler": { "verbose": true }
}
}Look for . The common cause is
nested imports; see .
[Transpiler] Used Babel for <file> Fallbackreferences/meteor-bundler-optimizations.md在中添加以下配置:
package.jsonjson
"meteor": {
"modern": true
}此配置将启用SWC、SWC压缩器、现代监视器以及开发模式下的web架构跳过功能。当出现不兼容情况时,各项功能会自动回退到旧版实现,因此该配置具备向后兼容性。
可选择性关闭部分功能:
json
"meteor": {
"modern": {
"transpiler": false,
"minifier": false,
"watcher": false,
"webArchOnly": false
}
}也可对SWC进行范围限制:、、、,支持设置为或路径/正则表达式数组。
transpiler.excludeApptranspiler.excludeNodeModulestranspiler.excludePackagestranspiler.excludeLegacytrue启用详细转译器日志以诊断Babel回退情况:
json
"meteor": {
"modern": {
"transpiler": { "verbose": true }
}
}查找日志信息。常见原因是嵌套导入,详情请查看。
[Transpiler] Used Babel for <file> Fallbackreferences/meteor-bundler-optimizations.mdEnable Rspack integration
启用Rspack集成
bash
meteor add rspackOn first run the package installs the project-level Rspack setup. App code
moves to Rspack; Meteor still handles Atmosphere packages and produces the
final bundle. Requires entry points in and no nested imports
in app code. To migrate an existing app, use the skill.
package.jsonmigrate-to-rspackrspack@meteorjs/rspack@rspack/core@rspack/clirspack@1.1.0@meteorjs/rspack@2.0.1rspack@1.2.0@meteorjs/rspack@2.1.0.meteor/versionspackage.jsonmeteor update --npmbash
meteor add rspack首次运行时,该包会安装项目级别的Rspack配置。应用代码将交由Rspack处理,Meteor仍负责管理Atmosphere包并生成最终打包文件。要求中存在入口点,且应用代码中无嵌套导入。如需迁移现有应用,请使用技能。
package.jsonmigrate-to-rspackrspack@meteorjs/rspack@rspack/core@rspack/clirspack@1.1.0@meteorjs/rspack@2.0.1rspack@1.2.0@meteorjs/rspack@2.1.0.meteor/versionspackage.jsonmeteor update --npmSWC config files
SWC配置文件
text
.swcrc > swc.config.js > swc.config.tsOnly the first found is used. Use for static config,
for environment-driven config. The file name must be exactly , not
.
.swcrcswc.config.js.swcrcconfig.swcrcInstall to externalize SWC helpers (smaller bundles):
@swc/helpersbash
meteor npm install --save @swc/helpersNew apps ship with this preinstalled. Normally no further setup is needed;
Meteor's pipeline detects it and emits imports instead of inlining. If only a
production or legacy bundle fails on a helper import, inspect Rspack-generated
and final Meteor output before changing or adding manual imports.
.swcrctext
.swcrc > swc.config.js > swc.config.ts仅会使用第一个找到的配置文件。使用用于静态配置,用于基于环境的动态配置。文件名必须严格为,不能是。
.swcrcswc.config.js.swcrcconfig.swcrc安装以外部化SWC辅助函数(减小打包体积):
@swc/helpersbash
meteor npm install --save @swc/helpers新创建的应用默认已预安装该包。通常无需进一步配置,Meteor的流水线会自动检测并生成导入语句而非内联代码。若仅生产环境或旧版打包文件出现辅助函数导入失败,请先检查Rspack生成的文件和Meteor最终输出,再修改或添加手动导入。
.swcrcRspack config files
Rspack配置文件
text
rspack.config.js | rspack.config.ts | rspack.config.mjs | rspack.config.cjsUse from . The function receives a
parameter with build flags and helpers. See
for the full table and the most useful
helpers (, , ,
, , , ,
, ).
defineConfig@meteorjs/rspackMeteorreferences/rspack-config.mdextendSwcConfigcompileWithRspackcompileWithMeteorextendConfigsplitVendorChunkpersistDevFilesdisablePluginsenablePortableBuildsetCachetext
rspack.config.js | rspack.config.ts | rspack.config.mjs | rspack.config.cjs使用来自的函数。该函数接收一个包含构建标志和辅助函数的参数。完整的参数表和最实用的辅助函数(、、、、、、、、)请查看。
@meteorjs/rspackdefineConfigMeteorextendSwcConfigcompileWithRspackcompileWithMeteorextendConfigsplitVendorChunkpersistDevFilesdisablePluginsenablePortableBuildsetCachereferences/rspack-config.md.meteorignore
.meteorignore
Skip directories the bundler does not need to watch. Same syntax as
. Place at any depth; rules apply to the subtree.
.gitignoregitignore
docs/
design/
cypress/
scripts/
*.md
!README.mdFor per-command rules, set the env var.
METEOR_IGNOREDo not copy into blindly. Exclude unrelated large
trees that Meteor does not need, but never match the active Rspack build context:
Meteor consumes its generated main and test modules during final assembly.
.gitignore.meteorignoreRspack also generates , ,
, and . Add those paths to the
native ignore configuration of recursive formatters, linters, typecheckers,
test discovery, coverage, and IDEs. alone is insufficient.
_build/public/build-assets/public/build-chunks/private/build-assets/.gitignore忽略打包器无需监视的目录,语法与相同。可放置在任意目录层级,规则仅适用于当前子树。
.gitignoregitignore
docs/
design/
cypress/
scripts/
*.md
!README.md如需为特定命令设置规则,请使用环境变量。
METEOR_IGNORE请勿盲目将复制到。忽略Meteor不需要的无关大型目录,但绝不能匹配Rspack的活动构建上下文:Meteor在最终组装过程中需要读取其生成的主模块和测试模块。
.gitignore.meteorignoreRspack还会生成、、和目录。请将这些路径添加到递归格式化工具、代码检查工具、类型检查工具、测试发现工具、覆盖率工具和IDE的原生忽略配置中,仅靠是不够的。
_build/public/build-assets/public/build-chunks/private/build-assets/.gitignoreMinifier ownership
压缩器归属
"modern": true"modern": trueProduction legacy builds
生产环境旧版构建
Dev skips and with .
Production still ships legacy by default. To drop legacy in production
too, add to :
web.browser.legacyweb.cordova"modern": truemodern.meteor/platformstext
server
browser
modern启用后,开发环境会跳过和。生产环境默认仍会打包旧版架构。若要在生产环境中也移除旧版架构,请将添加到:
"modern": trueweb.browser.legacyweb.cordovamodern.meteor/platformstext
server
browser
modernMemory limits
内存限制
Rspack runs as a child process and may OOM on large apps. Raise the heap
for tool processes temporarily when capturing evidence (Meteor 3.4.1+):
bash
TOOL_NODE_FLAGS="--max-old-space-size=16384" meteor runOn Meteor 3.4.0, use .
NODE_OPTIONS="--max-old-space-size=16384"First distinguish a one-shot build failure from growth during a long watch
session. Audit large directories visible to Meteor and check the exact release
for fixes. Test heap size and persistent cache as separate variables; revert a
change that does not improve the failure or a measured memory trend.
Rspack作为子进程运行,大型应用可能会出现内存不足(OOM)的情况。在捕获问题证据时,可临时提高工具进程的堆内存(Meteor 3.4.1及以上版本):
bash
TOOL_NODE_FLAGS="--max-old-space-size=16384" meteor run对于Meteor 3.4.0版本,请使用。
NODE_OPTIONS="--max-old-space-size=16384"首先区分是一次性构建失败还是长时间监视会话中的内存增长。检查Meteor可见的大型目录,并查看具体版本的修复情况。分别测试堆内存大小和持久化缓存的影响;若某项更改未能改善故障或内存趋势,请回退该更改。
Multiple instances
多实例运行
METEOR_LOCAL_DIR_buildbuild-assetsbuild-chunksbash
PORT=3000 METEOR_LOCAL_DIR=.meteor/local-1 meteor run
PORT=3001 METEOR_LOCAL_DIR=.meteor/local-2 meteor run使用隔离、、目录:
METEOR_LOCAL_DIR_buildbuild-assetsbuild-chunksbash
PORT=3000 METEOR_LOCAL_DIR=.meteor/local-1 meteor run
PORT=3001 METEOR_LOCAL_DIR=.meteor/local-2 meteor runAnti-patterns
反模式
- Enable optimizations and Rspack at the same time on a legacy app. Enable
first, clean up Babel fallbacks, then add Rspack.
"modern": true - Edit files inside ,
_build/,public/build-assets/, orpublic/build-chunks/. Autogenerated.private/build-assets/ - Assume prevents code-quality tools from scanning generated Rspack output. Configure each tool's own ignore mechanism.
.gitignore - Copy to
.gitignore. Git may ignore Rspack's generated handoff even though Meteor must read it..meteorignore - Remove a custom Atmosphere minifier only because Rspack is enabled. Benchmark the final production bundle first.
- Disable Rspack persistent cache without need. It is the default and the main rebuild-speed win. Disable only when investigating OOM or a cache-related Rspack bug.
- Name an SWC config or
config.swcrc. Onlyrc.swcis read..swcrc
- 在旧版应用上同时启用优化和Rspack:应先启用,解决Babel回退问题,再添加Rspack。
"modern": true - 编辑、
_build/、public/build-assets/或public/build-chunks/内的文件:这些目录是自动生成的。private/build-assets/ - 认为可以阻止代码质量工具扫描Rspack生成的输出:需要为每个工具单独配置忽略机制。
.gitignore - 将复制到
.gitignore:Git可能会忽略Rspack生成的交接文件,但Meteor必须读取这些文件。.meteorignore - 仅因启用Rspack就移除自定义Atmosphere压缩器:请先对最终生产打包文件进行基准测试。
- 无故禁用Rspack持久化缓存:这是默认配置,也是提升重建速度的主要手段。仅在排查OOM或缓存相关的Rspack bug时才禁用。
- 将SWC配置文件命名为或
config.swcrc:只有rc.swc会被读取。.swcrc
See also
另请参阅
references/meteor-bundler-optimizations.mdreferences/rspack-config.mdreferences/eval-cases.md- For converting an existing app to Rspack: skill.
migrate-to-rspack
references/meteor-bundler-optimizations.mdreferences/rspack-config.mdreferences/eval-cases.md- 如需将现有应用转换为兼容Rspack的版本:使用技能。
migrate-to-rspack