ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

Rolldown 未支持特性测试清单全解读:从 Rollup 兼容性测试窥探实现边界

Rolldown 未支持特性测试清单全解读:从 Rollup 兼容性测试窥探实现边界 Rolldown 未支持特性测试清单全解读从 Rollup 兼容性测试窥探实现边界【免费下载链接】rolldownFast Rust bundler for JavaScript/TypeScript with Rollup-compatible API.项目地址: https://gitcode.com/GitHub_Trending/ro/rolldown本篇文章聚焦 Rolldown 仓库中一份特殊的“豁免台账”——ignored-by-unsupported-features.md。它记录了 Rolldown 在运行 Rollup 官方测试套件时因尚未支持或未完全兼容的插件能力、输出选项与语言特性而被跳过的全部测试用例。读完本文你将理解这份清单的加载与执行机制、测试 ID 的编码规则、321 条被豁免用例背后的三大类兼容性差距以及如何用它追踪 Rolldown 与 Rollup 行为对齐的进度。这份清单的定位兼容性测试的“未支持特性”豁免台账Rolldown 的目标是与 Rollup 保持行为对齐其验证手段并非另起炉灶而是直接运行 Rollup 自己的测试套件。仓库中的 packages/rollup-tests/README.md 明确写道packages/rollup-tests/test下的每个测试用例都会代理到项目根目录rollupgit submodule 中的对应测试从而在 Rolldown 上复跑 Rollup 的全部测试。然而Rollup 与 Rolldown 的差距并非一蹴而就因此测试需要分层豁免。在packages/rollup-tests/src目录下共存在四种“跳过”机制各自针对不同的差距类型豁免文件含义ignored-tests.js已迁移到其他位置、依赖第三方插件、测试基础设施差异或属于“预期行为差异”的用例ignored-by-unsupported-features.md本文主题因 Rolldown 尚未支持/未完全兼容某项特性而被跳过的用例ignored-treeshaking-tests.js与 tree-shaking 相关、暂不参与对齐的用例ignored-passed-snapshot-different-tests.js行为已通过、但输出快照与 Rollup 不同的用例从当前 status.md 的统计可以看到这套体系的全貌状态分类数量failed0skipFailed296ignored106ignored(unsupported features)321ignored(treeshaking)327ignored(behavior passed, snapshot different)163passed1214也就是说在总计约 2400 余条 Rollup 测试中已有 1214 条完全通过而“未支持特性”豁免占据了 321 条——这是仅次于 tree-shaking 豁免的第二大差距来源也是理解 Rolldown 当前实现边界最直接的入口。清单如何被加载与执行从 Markdown 到测试跳过这份 Markdown 并不是给人看的静态说明它同时是机器可读的豁免规则文件。核心解析逻辑位于 packages/rollup-tests/src/intercept/utils.jsfunction loadUnsupportedFeaturesIgnoredTests() { const unsupportedIgnoredTests [] const content fs.readFileSync(path.join(__dirname, ../ignored-by-unsupported-features.md), utf-8) const matches content.match(/- (.*)/g) if (matches) { for (const id of matches) { unsupportedIgnoredTests.push(id.replace(- , ).trim()) } } return unsupportedIgnoredTests }解析规则非常朴素凡是文件中以-开头的行其内容即被视为一个测试 ID。随后的shouldIgnoredTest同文件 L67-L69会判断某个测试 ID 是否命中四种豁免集合之一function shouldIgnoredTest(id) { return ignoredTests.has(id) || ignoredSnapshotDifferentTests.has(id) || ignoredTreeshakingTests.has(id) || unsupportedFeaturesIgnoredTests.find((test) test.includes(id)) }实际跳过动作发生在测试运行器的钩子中。update-test-status.js 的beforeEach会在每个用例执行前检查shouldIgnoredTest(id)命中则直接this.currentTest?.skip()afterEach则统计通过/失败数量最终将结果写入status.json与status.md并在after钩子中强制process.exit(0)以避免残留的 Rust 进程阻塞测试结束。运行与更新状态的命令来自 justfilejust test-node-rollup运行测试just test-node-rollup --update运行并刷新状态文件注意--update与--grep互斥。测试 ID 的编码规则要读懂清单中的每一行必须先理解测试 ID 的生成方式。见 utils.jsfunction calcTestId(test) { const paths test.titlePath() return paths.join() }测试 ID 由 Mocha 的test.titlePath()数组以拼接而成因此形如rollupfunctionpreload-module: allows pre-loading modules via this.load含义为测试套件根rollup 测试目录function 用例名: 用例描述。常见的一级目录包括function构建行为与运行期行为测试对应 test/function/index.js 代理逻辑form输出格式/渲染快照测试hooks插件钩子执行语义测试sourcemapssourcemap 相关测试chunking form代码分割下的输出格式测试cli、watch、misc、typescript等其他套件部分 ID 末尾带generates es或cjs、system后缀表示该用例是同一目录在不同输出格式下的变体例如rollupformcompact: supports compact output with compact: truegenerates es。插件相关未支持特性Plugin related清单第一部分记录的是插件体系中的兼容性缺口共 17 组。这些特性主要涉及PluginContext能力、插件钩子返回值契约与并行插件机制是生态插件能否无缝迁移的关键。钩子参数与返回值契约的差异TheNormalizedOptionsat hooks is not compatible with rollupoptions/outputOptions 钩子中拿到的是未完全规范化Normalized的选项对象影响options-hook、output-options-hook两个用例——它们依赖在钩子中读取并修改规范化后的完整选项。Theloadhook returnastis not supportedload钩子返回自定义 ASTast字段目前不被支持豁免了uses-supplied-ast、custom-ast。TheresolveIdhookresolvedByis not supportedresolveId返回对象中的resolvedBy字段尚未实现豁免validate-resolved-by-logic。TheshouldTransformCachedModulehook is not supported缓存模块变换钩子缺失豁免plugin-error-should-transform。TheresolveDynamicImporthookspecifier: AstNodenot supported动态导入解析钩子无法接收原始 AST 节点豁免dynamic-import-unresolvable、dynamic-import-expression。TherenderDynamicImport/resolveImportMeta/shouldTransformCachedModulehooks not supported输出期动态导入渲染与 import.meta 解析钩子缺失豁免enforce-plugin-order。插件编排与并行语义The pluginsequentialis not supportedsequential: true声明保证并行钩子的顺序执行尚未实现豁免enforce-sequential-plugin-orderfunction 套件与 watch 模式下的同类用例。TherenderDynamicImporthook not supported自定义动态导入处理钩子缺失豁免custom-dynamic-import-no-interopgenerates es。PluginContext 能力缺口ThePluginContext.parsedoes not supportallowReturnOutsideFunctionoption上下文解析不支持在函数外返回语句豁免parse-return-outside-function。ThePluginContext.cacheis not supported插件级缓存 API 完全缺失共豁免 7 条用例匿名插件对 cache 的 delete/get/has/set各 1 条、重名插件无 cache key 时访问缓存、以及 2 条与 transform 缓存交互的 hooks 用例。ThePluginContext.loadis not fully supportedthis.load预加载能力不完整豁免preload-cyclic-module、preload-module、module-side-effectswritable、modify-meta——后两者涉及在resolveId阶段加载入口模块并修改ModuleInfo的语义。ThemaxParallelFileOpsis not supported并行文件操作数上限选项缺失豁免max-parallel-file-operations的 default/error/infinity/set/with-plugin 五条用例。ThePluginContext.emitFileemit chunk is only supported partially通过emitFile发射 chunk 仅部分支持主要缺口集中在隐式依赖implicit dependencies校验与文件名可用性时序共豁免 17 条implicit-dependencies*系列7 条、emit-fileset-asset-source-chunk、emit-filemodules-loaded、emit-fileinvalid-chunk-id、三个chunk-filename-not-available*buildEnd/renderStart/常规、file-references-in-bundle与hookscaches chunk emission in transform hook。ThePluginContext.emitFileemit prebuilt chunk is not supported发射预构建 chunk直接提供 code/filename缺失豁免prebuilt-chunk、invalid-prebuilt-chunk-filename、invalid-prebuit-chunk-code。ThePluginContext.setAssetSourceis not supported资源源码设置 API 缺失豁免 9 条用例包括空资源源码校验invalid2/3/4、transform 钩子中设置、outputOptions 钩子中设置、重复设置twice/twice2、非法 id以及hookskeeps emitted ids stable between runs。originalFileName/originalFileNamesis not supported properly发射资源时回传原始文件名到其他钩子的能力不完善豁免deprecatedemit-fileoriginal-file-name、original-file-name、original-file-names三条。import.meta.ROLLUP_FILE_URL_OBJ_*is not supported以 URL 对象形式引用发射资源的占位符缺失豁免resolve-file-url-objgenerates cjs与generates es两条。选项相关未支持特性Options related第二部分针对的是输入/输出选项层面的差距共 18 组。这些选项大多属于构建产物形态控制能力对追求“开箱即用替代 Rollup”的使用者影响最直接。输出格式与代码形态选项Theoutput.formatsystemjs is not supportedSystemJS 输出格式整体缺失是单组豁免量最大的选项类缺口共 20 条用例覆盖system-comments、system-default-comments、system-export-declarations、system-export-destructuring-declaration、system-export-rendering(-compact)、system-module-reserved、system-multiple-export-bindings、system-null-setters、system-reexports、system-semicolon、system-uninitialized、import-namespace-systemjs、modify-export-semi等全部渲染细节。Theformat: amdnot supportedAMD 格式的选项校验缺失豁免amd-auto-id-id、amd-base-path-id、amd-base-path三条均涉及amd.autoId/amd.basePath/amd.id的组合冲突校验。Theoutput.compactis not supported紧凑输出模式缺失豁免inlined-dynamic-namespace-compact、compact、compact-multiple-importsgenerates es、formcompactgenerates es。Theoutput.validateis not supported输出代码语法校验选项缺失豁免validate-output。Theoutput.interopis not supportedCJS/外部模块 interop 策略完全未实现是第二大的选项类豁免组共 16 条覆盖interop-auto-live-bindings、interop-auto-no-live-bindings、interop-default-conflict、interop-default-only*系列、interop-default、interop-esmodule、invalid-interop、deconflicts-interop、interop-per-dependency*与interop-per-reexported-dependency。Theoutput.generatedCodeis not supported产物代码风格选项缺失豁免 arrow-functions、const-bindings、object-shorthand、reserved-names-as-props 四个子项的 true/false 全组合function/form 双套件及unknown-generated-code-value。Theoutput.generatedCode.presetis not supported代码风格预设缺失豁免generated-code-presetses2015、es5、preset-with-override与unknown-generated-code-preset。注意在测试代理 test/function/index.js 中Rolldown 默认使用generatedCode.preset: es2015而测试侧统一强制为es5以保证对比基准一致。Theoutput.generatedCode.symbolsis not supported properlySymbol.toStringTag相关产物符号生成不完善豁免name-conflict-symbol、namespace-tostring*系列dynamic-import-default-mode/dynamic-import/external-namespaces/property-descriptor共 4 条。Theoutput.sourcemapBaseUrlis not compatible yetsourcemap 基础 URL 前缀选项不兼容豁免sourcemap-base-url-invalid、sourcemap-base-url-without-trailing-slashgenerates es、sourcemap-base-urlgenerates es。模块组织与分块选项Theoutput.preserveModulesis not compatible yet保留模块结构的输出模式尚不兼容豁免 12 条用例preserve-modules-default-mode-namespace、circular-preserve-modules、missing-export-preserve-modules、preserve-modules-circular-order、preserve-modules*校验系列invalid-default-export-mode/invalid-no-preserve-entry-signatures/invalid-none-export-mode/manual-chunks/mixed-exports、synthetic-named-exportspreserve-modules、circular-namespace-reexport-preserve-modules。Theoutput.manualChunksis not compatible手动分块能力不兼容豁免 8 条manual-chunks-conflict、manual-chunks-include-external-modules(-3)、manual-chunks-info、circular-namespace-reexport-manual-chunks、emit-chunk-manual-asset-source、emit-chunk-manual、manual-chunks-order。Theoutput.treeshake.presetis not supportedtree-shaking 预设缺失豁免unknown-treeshake-preset。Theoutput.treeshake.moduleSideEffectis not compatible with rollupmoduleSideEffects与插件resolveId的交互语义不兼容豁免module-side-effectsresolve-id-external与module-side-effectsresolve-id。输入侧选项与产物 APITheinput.perfandbundle.getTimings()is not supported性能计时选项与getTimings()API 缺失豁免adds-timings-to-bundle-when-codesplitting、adds-timings-to-bundle。Theinput.moduleContextis not supported模块级this上下文定制选项缺失豁免custom-module-context-function、custom-module-contextgenerates es。TheBundle.cacheis not supportedbundle对象的cache/modules数组信息缺失豁免module-tree#903、has-modules-array。TheModuleInfois not compatible with rollup插件可见的模块信息对象不兼容豁免 9 条plugin-module-information(-no-cache)、module-parsed-hook、has-default-export、context-resolve、check-exports-exportedBindings-as-a-supplementary-test、load-resolve-dependenciesimportedIdResolutions、resolve-relative-external-id。The chunk information is not compatible with rollupchunk 级信息不兼容豁免formaddon-functionsgenerates es与hookssupports generateBundle hook including reporting rendered exports and source length涉及modules.dep.renderedExports/removedExports。功能特性相关未支持Features第三部分记录的是语言特性与运行期语义层面的差距共 14 组是三类中粒度最细、最接近 ECMAScript 规范的部分。ThesyntheticNamedExportsis not supported合成具名导出特性整体缺失是全文最大的单组豁免共 28 条覆盖入口/动态导入/命名空间/循环依赖/跨 chunk 去冲突/回退导出fallback/in运算符优化等全部语义。Import Assertions is not supportedassert形式的导入断言缺失豁免 6 条plugin-assertions-this-resolve两条、warn-assertion-conflicts、warn-unresolvable-assertions、deprecatedremoves-dynamic-assertions、deprecatedremoves-static-attributes。Import attributes is not supportedwith形式的导入属性缺失共 21 条覆盖静态/动态导入属性的保留与移除、插件在resolveId/resolveDynamicImport中读写属性、resolveFileUrl/resolveImportMeta附加属性、configure-file-url、以及 deprecated 的load/transform返回属性行为。Source phase import is not supportedimport source阶段导入缺失豁免 5 条source-phase-imports-external、source-phase-dynamic-import-error(-resolved)、source-phase-format-unsupported、source-phase-import-error。watch behavior is not compatible yetwatch 模式行为不兼容豁免hooksallows to enforce plugin hook order in watch mode。escaping external id is not supported外部模块 ID 的引号转义处理缺失豁免formquote-idgenerates es。removeuse strictfrom function body从函数体中移除use strict指令的行为缺失豁免function-use-strict-directive-removed。The namespace object is not compatible with rollup命名空间对象语义不兼容null 原型、冻结、arguments占位、动态导入默认导出模式、外部实时绑定等共 13 条包括namespaces-have-null-prototype、namespaces-are-frozen、namespace-override、escape-arguments、dynamic-import-only-default、dynamic-import-default-mode-facade、chunking-duplicate-reexport、namespace-tostringinterop-property-descriptor、external-dynamic-import-live-binding(-compact)、no-external-live-bindings(-compact)。hasOwnPropertyexport is not handled properly导出名为hasOwnProperty时的语义处理不完善豁免re-export-own。__proto__export is not properly handled导出名为__proto__时与 CJS 转译器的交互不完善豁免cjs-transpiler-re-exports-1、cjs-transpiler-re-exports均generates cjs涉及output.externalLiveBindings与output.reExportProtoFromExternal。source map combine logic does not support coarse sourcemap well enough粗粒度 sourcemap 的合并逻辑不足豁免combined-sourcemap-3generates es。strictDeprecationsoption is not supported严格弃用告警选项缺失豁免deprecations*系列 7 条externalImportAssertions、asset-filename-name、asset-filename-originalfilename、asset-name-in-bundle、asset-originalfilename-in-bundle、asset-render-chunk-originalfilename-in-bundle、asset-render-chunk-name-in-bundle。The error/warning information is not compatible with rollup错误/警告的信息载体不兼容错误码、cause属性、日志钩子语义豁免 8 条例如banner-and-footer期望ADDON_ERROR实得PLUGIN_ERROR、conflicting-reexportsnamed-import期望AMBIGUOUS_EXTERNAL_NAMESPACES实得MISSING_EXPORT、logginghandle-logs-in-plugins、supports renderError hook等。The error/warning not implement错误/警告类型本身尚未实现是清单中条目最多的单组约 55 条几乎每一行都标注了“期望的 Rollup 错误/警告码 vs Rolldown 实际产物”例如INVALID_OPTIONvsGenericFailure、VALIDATION_ERRORvsInvalidArg、MISSING_EXPORT应为警告而非错误、EMPTY_BUNDLE/NAMESPACE_CONFLICT/THIS_IS_UNDEFINED/SOURCEMAP_ERROR/INVALID_ANNOTATION等告警的缺失或错位。部分条目还标注了上游来源如ast-validationsredeclare-import-var关联 oxc-project/oxc issue #15961。从清单到实现兼容性差距的观测与演进清单是活文档也是 roadmap这份清单不是一次性产物。任何开发者都可以在修复某项特性后从文件中删除对应的-行使相关测试重新进入执行队列反向地新增未支持特性时也应把对应测试 ID 追加进来。由于解析逻辑完全基于-前缀的行匹配维护时只需遵守“一行一个测试 ID”的格式约定即可无需改动 intercept/utils.js 的代码。测试代理与格式变体被豁免的用例大多仍由 test/function/index.js 等代理文件按 Rollup 原样加载其测试样本目录指向../../../../rollup/test/function/samples即根目录 git submodule。代理层还会为对比公平性注入一些默认值例如禁用inlineConst优化、默认dynamicImportInCjs: true、强制generatedCode.preset: es5等因此清单中generates es/cjs/system后缀标识的变体正是同一用例在多格式参数化下的独立 ID。如何自行验证当前状态在项目根目录执行just test-node-rollup即可复现测试使用just test-node-rollup --update会在结束后刷新 status.json 与 status.md。运行期间update-test-status.js会为每个用例打印其 IDconsole.log(id)便于对照清单逐条核验某个用例若从“ignored(unsupported features)”转为通过通常意味着对应特性已落地。结语ignored-by-unsupported-features.md表面上是一份被跳过的测试列表实际上是一张经过机器验证的兼容性差距地图插件体系PluginContext、emitFile、缓存、钩子契约、选项体系SystemJS/AMD 格式、interop、generatedCode、preserveModules/manualChunks、语言特性syntheticNamedExports、import attributes、source phase import、namespace 语义三大维度的边界被 321 条用例精确锚定。对于使用 Rolldown 的开发者它是排查“为什么这个 Rollup 选项/插件行为不一致”的权威索引对于贡献者它则是按图索骥、逐项消除差距的路线图——每删掉一行-开头的内容就意味着 Rolldown 与 Rollup 的行为对齐又前进了一步。【免费下载链接】rolldownFast Rust bundler for JavaScript/TypeScript with Rollup-compatible API.项目地址: https://gitcode.com/GitHub_Trending/ro/rolldown创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表