From 07138fd999f9f0f8e497e937262928e569546958 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sun, 1 Nov 2020 11:10:18 +0100 Subject: [PATCH 1/2] fix: only require parsers if need be this also allows to remove them from bundle. However this is not the best way. We should use global vars for cssParser so that weback automatically removes the code --- packages/core/ui/styling/style-scope.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/ui/styling/style-scope.ts b/packages/core/ui/styling/style-scope.ts index 76b74e55c..a85a35c9e 100644 --- a/packages/core/ui/styling/style-scope.ts +++ b/packages/core/ui/styling/style-scope.ts @@ -2,9 +2,7 @@ import { Keyframes } from '../animation/keyframe-animation'; import { ViewBase } from '../core/view-base'; import { View } from '../core/view'; import { unsetValue, _evaluateCssVariableExpression, _evaluateCssCalcExpression, isCssVariable, isCssVariableExpression, isCssCalcExpression } from '../core/properties'; -import { SyntaxTree, Keyframes as KeyframesDefinition, parse as parseCss, Node as CssNode } from '../../css'; -import { CSS3Parser, CSSNativeScript } from '../../css/parser'; -import { cssTreeParse } from '../../css/css-tree-parser'; +import { SyntaxTree, Keyframes as KeyframesDefinition, Node as CssNode } from '../../css'; import { RuleSet, SelectorsMap, SelectorCore, SelectorsMatch, ChangeMap, fromAstNodes, Node } from './css-selector'; import { Trace } from '../../trace'; @@ -214,10 +212,12 @@ class CSSSource { if (this._source) { switch (parser) { case 'css-tree': + const cssTreeParse = require('../../css/css-tree-parser').pacssTreeParserse; this._ast = cssTreeParse(this._source, this._file); - return; case 'nativescript': + const CSS3Parser = require('../../css/parser').CSS3Parser; + const CSSNativeScript = require('../../css/parser').CSSNativeScript; const cssparser = new CSS3Parser(this._source); const stylesheet = cssparser.parseAStylesheet(); const cssNS = new CSSNativeScript(); @@ -225,6 +225,7 @@ class CSSSource { return; case 'rework': + const parseCss = require('../../css').parse; this._ast = parseCss(this._source, { source: this._file }); return; From 3a7467223c51833865f84e255d476b590618b93e Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Tue, 3 Nov 2020 11:36:15 +0100 Subject: [PATCH 2/2] fix: typo fix --- packages/core/ui/styling/style-scope.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/ui/styling/style-scope.ts b/packages/core/ui/styling/style-scope.ts index a85a35c9e..e1bac012a 100644 --- a/packages/core/ui/styling/style-scope.ts +++ b/packages/core/ui/styling/style-scope.ts @@ -212,7 +212,7 @@ class CSSSource { if (this._source) { switch (parser) { case 'css-tree': - const cssTreeParse = require('../../css/css-tree-parser').pacssTreeParserse; + const cssTreeParse = require('../../css/css-tree-parser').cssTreeParse; this._ast = cssTreeParse(this._source, this._file); return; case 'nativescript':