feat(minify): add directives option#15690
Conversation
I don't think so. If the code is not ESM, then the code should be parsed with Script mode, which makes |
|
You're right. There is also a problem with detecting module type here output { span: Span { start: 0, end: 35 }, source_text: ""use strict";\n\nexports.foo = 'foo'\n", comments: Vec([]), hashbang: None, directives: Vec([Directive { span: Span { start: 0, end: 13 }, expression: StringLiteral { span: Span { start: 0, end: 12 }, value: "use strict", raw: Some(""use strict""), lone_surrogates: false }, directive: "use strict" }]), body: Vec([ExpressionStatement(ExpressionStatement { span: Span { start: 15, end: 34 }, expression: AssignmentExpression(AssignmentExpression { span: Span { start: 15, end: 34 }, left: StaticMemberExpression(StaticMemberExpression { span: Span { start: 15, end: 26 }, object: Identifier(IdentifierReference { span: Span { start: 15, end: 22 }, name: "exports", reference_id: Cell { value: Some(ReferenceId(0)) } }), property: IdentifierName { span: Span { start: 23, end: 26 }, name: "foo" }, optional: false }), right: StringLiteral(StringLiteral { span: Span { start: 29, end: 34 }, value: "foo", raw: Some("'foo'"), lone_surrogates: false }), operator: Assign }) })]), scope_id: Cell { value: Some(ScopeId(0)) }, source_type: SourceType { language: JavaScript, module_kind: Module, variant: Standard } } source_type module_kind = Module |
|
At present, it seems that adding this configuration is still quite necessary |
|
At present, it seems that adding this configuration is still quite necessary can you elaborate your use case? I try to avoid adding options until it's necessary for a specific modern usecase. |
|
I think #15691 solved the same problem without a new option. |
https://terser.org/docs/options/
When the js module is of the Module type, it may output from ejs to cjs. Therefore, we add this configuration to keep it similar to terser
It is possible to fix the related issues
rolldown/rolldown#6880
rolldown/rolldown#6879