Re-organize @stylable/core #1991
Labels
core
Processing and transforming logic
dev velocity
plan
a plan for organizing larger amounts of work
tech debt
Updates, upgrades, stale code and work-arounds
description
organize
@stylable/core
in order to achieve improved code flow that is intuitive and predictable for searching implementation and tests.The issues we face today while developing Stylable:
blocked by (dependencies)
PR that set a new selector parser and started the deprecating process- refactor(core): integrate new CSS selector parser (from Tokey) #1884tasks overview
System to manage features
The main issue with testing e2e "features" in Stylable is the fact that they are interleaved in implementation, tests and usage. That makes it impossible to arbitrary decide how to breakdown specs and where a feature should be tested.
I suggest we keep an ordered list of features and make sure that tests are written in the lowest feature spec that is being tested. For example if a test uses
@st-import
and@property
and custom properties is first on the list, then the test would be under thest-import.spec
.test/features
analyze
andtransform
phasesbreakdown the big process
src/features
src/helpers
helpers
resolve
escape
deprecation
rule
selector
declaration
global
context
passed across the entire process
production
|development
process breakdown suggestion
New flow will have a cleaner
StylableMeta
that will hold private states for theanalyze
andtransform
flowsanalyzeStylesheet (previously
stylable-processor
)Analyze a single stylesheet into a state that can be cached against the content of the stylesheet.
StylableMeta
analyzeInit
st-import
- collect import symbols - check symbols re-declaration, default, named, keyframes (need to discuss) // ToDo: deprecate:import
analyzeAtRule<NAME>
st-namespace
- collectcss-keyframes
- collectcss-custom-selector
- collectst-scope
- collect // ToDo: move validation herecss-property
- collect + check redeclare symbol (@st-global-custom-property
)analyzeSelectorNode<AST_TYPE, VALUE>
- walk selector ASTst-import
- check deprecated syntax:import
st-var
- check (soon to be) deprecated syntax:vars
st-part
- add part symbolst-part
- add type symbol, aliascss-id
- validate no functional apicss-class
- collect class symbolscss-attribute
- validate no functional apicss-nesting
- validate no functional apianalyzeRule
st-part
- validate root position in selectorcss-nesting
- unsupported - check no nested rulesanalyzeDeclaration<PROP>
st-class
- collect-st-states
st-class
- collect-st-extends
st-class
- add to-st-global
st-mixin/partialMixin
// ToDo: stop setting on Rulecss-property
- collect css var (set)analyzeDeclarationValue<PART>
- walk value ASTcss-property
- collectvar()
(get)css-asset
- collecturl()
// ToDo: check if required (might be doubled checked in transformer because of mixins)onAnalyzeComplete
st-custom-selector
- temp keep removing rulecss-property
- temp keep removing the rule (@st-global-custom-property
)st-scope
- merge scoped selectors // ToDo: stop changing source ASTst-var
- temp keep removing:vars
st-import
- temp keep removing:import
/@import
st-namespace
- set namespace on meta + temp keep removing rule // might be part of createStylesheetMeta and not the analyzetransformStylesheet (previously
stylable-transformer
)Picks up after the meta has been created and when dependencies are available, transform the
sourceAST
intotargetAST
while adding diagnostics.sourceAST
intotargetAST
transformInit
global
st-scope
validate scopes keep track of scopes // ToDo: remove as part of not flattening@st-scope
in the processorst-import
- validate importscss-var
- collect local & imported varstransformSelector
- transform rule selector + keep track of nested selector typetransformAtRule<NAME>
css-keyframes
- namespace keyframes namecss-media
- transform innervalue()
function in paramscss-property
- namespace propertyst-scope
- [future] transform selector & keep track of selector subject type (to set as "anchor" for inner rules)transformDeclaration
transformExpandRules
- or maybeafterRulesTransform
st-class
- add dev time browser placement invalidation for-st-extends
st-mixin
- expand mixin into AST // ToDo: check if the removal of-st-mixin
can be delayed totransformCleanup
transformCleanup
// this might not be a feature phase, but a place that removes AST nodes that have been registered throughout the processst-global
- collect:global()
selectors and flatten selectorsst-mixin
- remove mixin declarations?*
- remove any other stylable build instructionsgetJsExports
st-part
st-var
css-keyframes
css-property
transformSelector
accepts selector + initial selector context, transform and return the type information at the end of the selector
transformSelectorNode<AST_TYPE, VALUE>
- iterate selectorcss-class
- namespace & set context forclass
// ToDo: also validates-st-states
here, need to check if there is a better placepseudo_elements
css-custom-selector
- // ToDo: research processst-part
- namespace & set context for customcss-type
- namespace & set context non native typecss-pseudo-class
- transform functional inner selectors & namespace custom statecss-nesting
- set context to origin // ToDo: check cases when this is requiredtransformRule
st-custom-selector
- generate multiple selectors if neededtransformDeclaration
transformDeclaration
- iterate declarationscss-keyframes
- namespace animation / animation namecss-property
- namespace properties in proptransformDeclarationValue<PROP, PART>
- walk value ASTst-var
- transformvalue()
function in declarations value (including custom vars likest-map
,st-array
, etc)css-asset
css-font
- handleformat()
in@font-face
st-formatter
css-property
- transformvar()
tasks
private meta state for process flows to storage each feature data
build context interface to pass down to features
base
stylable
@namespace
(conflict) #2624extended CSS
@property
,--x
,var(--x)
) - fix(core): css-custom-property feature overall #2216move code to the proper helpers
remove custom selector stubs from the processor process refactor(core): prepare process AST mods for move to transform #2489
transformer split
processDeclarationValue
into the various features (url, value, format ofcss-font
, var), and move flow intotransformDeclaration
(might need to offer as public api on the main transformer in order to allow single value transformation from various flows)context
,handleSelectorNode
,transformSelectorAst
into the newtransformSelector
remove transformations from analyze process refactor: move prepare ast to transformer #2496
@namespace
:vars
@custom-selector
@st-scope
@st-imports
/:import
remove middle format AST (keep just sourceAST, targetAST) refactor(core)!: removed processed AST from meta #2525
stop extending
postcss.Rule
withmixins
- prefer a static util for collection that is not part of theanalyzeStylesheet
or an another alternative methodresearch order feature test order or alternative (how does other similar projects order tests)
test/features/*.spec.ts
document dev process in repo wiki
deprecate
stylable-transformer
andstylable-processor
proceed with more research on moving optimization as part of the transformer
The text was updated successfully, but these errors were encountered: