Open ackava opened 2 years ago
where would someone who wants to contribuite to this change start? do you have suggestions @RyanCavanaugh ?
Is it in src/compiler/transformers/module/node.ts
? to be more exact in createSettersArray
factory.createPropertyAssignment( // line: 486
factory.createStringLiteral(idText(e.name)),
factory.createElementAccessExpression(
parameterName,
factory.createStringLiteral(idText(e.propertyName || e.name))
)
)
); // line: 494
It would be someting like changing this part with the execute one but I'm I little bit confused with the flow that runs in this file.
where it creates the var n_1
variable and .default
for the execute part ?
edit: I was searching for the starting point
// Line: 268
const moduleObject = factory.createObjectLiteralExpression([
factory.createPropertyAssignment("setters",
createSettersArray(exportStarFunction, dependencyGroups)
),
factory.createPropertyAssignment("execute",
factory.createFunctionExpression(
modifiers,
/*asteriskToken*/ undefined,
/*name*/ undefined,
/*typeParameters*/ undefined,
/*parameters*/ [],
/*type*/ undefined,
factory.createBlock(executeStatements, /*multiLine*/ true)
)
)
], /*multiLine*/ true);
SystemJS Module
Lets assume module "n" as following,
Following code,
Results in
This is problem, every time when we refer
n
, internally it is referringn_1.default
. Every access to imported symbol results in two step property access.However, if we move
n_1.default
in the setter instead of every access, the logic remains same.Suggestion
Code generation can be changed to,
There are two benefits,
Why this is important over minification
PLEASE READ We cannot minimize this by enabling short circuit property chains as minimizing property chains creates problem other logic where minimizer does not support conditional minimizing.
Babel plugin does it correctly, https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=false&spec=false&loose=false&code_lz=JYWwDg9gTgLgBAOzgMyhEcBEA6A9AzAbgCgBjCBAZ3krAEMkBeOAEwlIFcQBTBGbUlG50Y3AKIAbbjz4AKTAGUACgEEAcpgCUJNpxn8ARhBYBPbHTBheLAMIALYBJazaDbcUrcYAST7coAG50ErKymnCMAHxwxHBxcK4I2KIAHjA2FKJ8EYgANHAAjAAMJdpAA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2%2Ctypescript&prettier=false&targets=&version=7.18.4&externalPlugins=babel-plugin-transform-es2015-modules-systemjs%406.24.1&assumptions=%7B%7D
✅ Viability Checklist
My suggestion meets these guidelines: