@tarojs/rn-style-transformer 3.5.0-canary.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/config.spec.js +1 -1
- package/__tests__/index.spec.js +14 -0
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/transforms/StyleSheet/ColorPropType.js +1 -1
- package/dist/transforms/StyleSheet/ColorPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/ImageResizeMode.js +1 -1
- package/dist/transforms/StyleSheet/ImageResizeMode.js.map +1 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js +5 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/LayoutPropTypes.js +5 -1
- package/dist/transforms/StyleSheet/LayoutPropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js +5 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js.map +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js.map +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js +5 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/TransformPropTypes.js +10 -6
- package/dist/transforms/StyleSheet/TransformPropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js +5 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js.map +1 -1
- package/dist/transforms/index.js +36 -37
- package/dist/transforms/index.js.map +1 -1
- package/dist/transforms/less.js +29 -6
- package/dist/transforms/less.js.map +1 -1
- package/dist/transforms/postcss.js +38 -15
- package/dist/transforms/postcss.js.map +1 -1
- package/dist/transforms/sass.js +38 -18
- package/dist/transforms/sass.js.map +1 -1
- package/dist/transforms/stylus.js +3 -3
- package/dist/transforms/stylus.js.map +1 -1
- package/dist/utils/index.js +41 -18
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lessImport.js +1 -1
- package/dist/utils/lessImport.js.map +1 -1
- package/package.json +19 -24
- package/src/index.ts +17 -2
- package/src/transforms/index.ts +19 -25
- package/src/transforms/less.ts +32 -31
- package/src/transforms/postcss.ts +11 -10
- package/src/transforms/sass.ts +10 -9
- package/src/transforms/stylus.ts +17 -16
- package/src/utils/index.ts +9 -8
- package/src/utils/lessImport.ts +1 -0
- package/tsconfig.json +5 -24
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.makePostcssPlugins = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
30
|
+
const helper_1 = require("@tarojs/helper");
|
|
31
|
+
const path = __importStar(require("path"));
|
|
9
32
|
const postcss_1 = __importDefault(require("postcss"));
|
|
10
|
-
const postcss_pxtransform_1 = __importDefault(require("postcss-pxtransform"));
|
|
11
33
|
const postcss_import_1 = __importDefault(require("postcss-import"));
|
|
12
|
-
const
|
|
34
|
+
const postcss_pxtransform_1 = __importDefault(require("postcss-pxtransform"));
|
|
35
|
+
const resolve_1 = require("resolve");
|
|
36
|
+
const rn_stylelint_json_1 = __importDefault(require("../config/rn-stylelint.json"));
|
|
13
37
|
const utils_1 = require("../utils");
|
|
14
38
|
const reporterSkip_1 = __importDefault(require("../utils/reporterSkip"));
|
|
15
|
-
const rn_stylelint_json_1 = __importDefault(require("../config/rn-stylelint.json"));
|
|
16
39
|
const defaultPxtransformOption = {
|
|
17
40
|
enable: true,
|
|
18
41
|
config: {
|
|
@@ -27,41 +50,41 @@ function makePostcssPlugins({ filename, designWidth, deviceRatio, postcssConfig,
|
|
|
27
50
|
if (deviceRatio) {
|
|
28
51
|
defaultPxtransformOption.config.deviceRatio = deviceRatio;
|
|
29
52
|
}
|
|
30
|
-
const pxtransformOption = helper_1.recursiveMerge({}, defaultPxtransformOption, postcssConfig.pxtransform);
|
|
53
|
+
const pxtransformOption = (0, helper_1.recursiveMerge)({}, defaultPxtransformOption, postcssConfig.pxtransform);
|
|
31
54
|
const plugins = [
|
|
32
|
-
postcss_import_1.default({
|
|
55
|
+
(0, postcss_import_1.default)({
|
|
33
56
|
resolve: function resolve(id, basedir, options) {
|
|
34
|
-
return utils_1.resolveStyle(id, Object.assign(Object.assign({}, options), { basedir, defaultExt: '.css', alias: postcssConfig.alias, platform: transformOptions.platform }));
|
|
57
|
+
return (0, utils_1.resolveStyle)(id, Object.assign(Object.assign({}, options), { basedir, defaultExt: '.css', alias: postcssConfig.alias, platform: transformOptions.platform }));
|
|
35
58
|
}
|
|
36
59
|
})
|
|
37
60
|
];
|
|
38
61
|
if (pxtransformOption.enable) {
|
|
39
|
-
plugins.push(postcss_pxtransform_1.default(pxtransformOption.config));
|
|
62
|
+
plugins.push((0, postcss_pxtransform_1.default)(pxtransformOption.config));
|
|
40
63
|
}
|
|
41
64
|
const skipRows = additionalData ? additionalData.split('\n').length : 0;
|
|
42
|
-
plugins.push(require('stylelint')(rn_stylelint_json_1.default), reporterSkip_1.default({ skipRows, filename }), require('postcss-reporter')({ clearReportedMessages: true }));
|
|
65
|
+
plugins.push(require('stylelint')(rn_stylelint_json_1.default), (0, reporterSkip_1.default)({ skipRows, filename }), require('postcss-reporter')({ clearReportedMessages: true }));
|
|
43
66
|
Object.entries(postcssConfig).forEach(([pluginName, pluginOption]) => {
|
|
44
67
|
if (optionsWithDefaults.indexOf(pluginName) > -1)
|
|
45
68
|
return;
|
|
46
69
|
if (!pluginOption || !pluginOption.enable)
|
|
47
70
|
return;
|
|
48
|
-
if (!helper_1.isNpmPkg(pluginName)) { // local plugin
|
|
49
|
-
pluginName =
|
|
71
|
+
if (!(0, helper_1.isNpmPkg)(pluginName)) { // local plugin
|
|
72
|
+
pluginName = path.join(process.cwd(), pluginName);
|
|
50
73
|
}
|
|
51
74
|
try {
|
|
52
|
-
const pluginPath = resolve_1.sync(pluginName, { basedir: process.cwd() });
|
|
75
|
+
const pluginPath = (0, resolve_1.sync)(pluginName, { basedir: process.cwd() });
|
|
53
76
|
plugins.push(require(pluginPath)(pluginOption.config || {}));
|
|
54
77
|
}
|
|
55
78
|
catch (e) {
|
|
56
79
|
const msg = e.code === 'MODULE_NOT_FOUND' ? `缺少postcss插件${pluginName}, 已忽略` : e;
|
|
57
|
-
helper_1.printLog(msg, "warning" /* WARNING */);
|
|
80
|
+
(0, helper_1.printLog)(msg, "warning" /* processTypeEnum.WARNING */);
|
|
58
81
|
}
|
|
59
82
|
});
|
|
60
83
|
return plugins;
|
|
61
84
|
}
|
|
62
85
|
exports.makePostcssPlugins = makePostcssPlugins;
|
|
63
86
|
function transform(src, filename, { options, plugins }) {
|
|
64
|
-
return postcss_1.default(plugins)
|
|
87
|
+
return (0, postcss_1.default)(plugins)
|
|
65
88
|
.process(src, Object.assign({ from: filename }, options))
|
|
66
89
|
.then(result => {
|
|
67
90
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcss.js","sourceRoot":"","sources":["../../src/transforms/postcss.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postcss.js","sourceRoot":"","sources":["../../src/transforms/postcss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoF;AACpF,2CAA4B;AAC5B,sDAAiD;AACjD,oEAA0C;AAC1C,8EAA6C;AAC7C,qCAA6C;AAE7C,oFAAyD;AACzD,oCAAuC;AACvC,yEAAgD;AAWhD,MAAM,wBAAwB,GAE1B;IACF,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI;KACf;CACF,CAAA;AAED,SAAgB,kBAAkB,CAAE,EAClC,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf;IACC,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;IAE5G,IAAI,WAAW,EAAE;QACf,wBAAwB,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;KAC1D;IAED,IAAI,WAAW,EAAE;QACf,wBAAwB,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;KAC1D;IACD,MAAM,iBAAiB,GAAG,IAAA,uBAAc,EAAC,EAAE,EAAE,wBAAwB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;IAEjG,MAAM,OAAO,GAAG;QACd,IA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AAG,IAAA,cAAW,EAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACtE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAE,YAAoB,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAA;SACtE;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,cAAc,UAAU,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/E,IAAA,iBAAQ,EAAC,GAAG,0CAA0B,CAAA;SACvC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC;AAlED,gDAkEC;AAED,SAAwB,SAAS,CAAE,GAAW,EAAE,QAAgB,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;IACpF,OAAO,IAAA,iBAAO,EAAC,OAAO,CAAC;SACpB,OAAO,CAAC,GAAG,kBAAI,IAAI,EAAE,QAAQ,IAAK,OAAO,EAAG;SAC5C,IAAI,CAAC,MAAM,CAAC,EAAE;QACb,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC;AAND,4BAMC"}
|
package/dist/transforms/sass.js
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
26
|
+
const fs = __importStar(require("fs"));
|
|
27
|
+
const path = __importStar(require("path"));
|
|
8
28
|
const utils_1 = require("../utils");
|
|
9
29
|
/**
|
|
10
30
|
* 用过用户手动安装了 node-sass,启用node-sass,默认使用 sass
|
|
@@ -27,22 +47,22 @@ function getSassImplementation() {
|
|
|
27
47
|
}
|
|
28
48
|
const sassImplementation = getSassImplementation();
|
|
29
49
|
function makeURL(resource, rootDir) {
|
|
30
|
-
const url =
|
|
31
|
-
if (!
|
|
50
|
+
const url = path.resolve(rootDir, resource);
|
|
51
|
+
if (!fs.existsSync(url)) {
|
|
32
52
|
throw new Error(`全局注入 scss 文件路径错误: ${url}`);
|
|
33
53
|
}
|
|
34
54
|
return url;
|
|
35
55
|
}
|
|
36
56
|
function makeImportStatement(filePath, resource, rootDir) {
|
|
37
57
|
const url = makeURL(resource, rootDir);
|
|
38
|
-
const relativePath =
|
|
58
|
+
const relativePath = path.relative(filePath, url).replace(/\\/g, '/'); // fix window path error
|
|
39
59
|
return `@import './${relativePath}'`;
|
|
40
60
|
}
|
|
41
61
|
function getGlobalResource(filename, config) {
|
|
42
62
|
var _a;
|
|
43
63
|
let resource = '';
|
|
44
64
|
const projectDirectory = config.projectDirectory || process.cwd();
|
|
45
|
-
const filePath =
|
|
65
|
+
const filePath = path.dirname(path.resolve(projectDirectory, filename));
|
|
46
66
|
if (typeof config.resource === 'string') {
|
|
47
67
|
resource = makeImportStatement(filePath, config.resource, projectDirectory);
|
|
48
68
|
}
|
|
@@ -51,14 +71,14 @@ function getGlobalResource(filename, config) {
|
|
|
51
71
|
resource = resources.join(';\n');
|
|
52
72
|
}
|
|
53
73
|
// https://taro-docs.jd.com/taro/docs/config-detail/#sassdata, data 覆盖 resurce 配置
|
|
54
|
-
return utils_1.insertAfter(resource, config === null || config === void 0 ? void 0 : config.data);
|
|
74
|
+
return (0, utils_1.insertAfter)(resource, config === null || config === void 0 ? void 0 : config.data);
|
|
55
75
|
}
|
|
56
76
|
function combineResource(src, filename, config) {
|
|
57
77
|
// sass config
|
|
58
|
-
const globalResource = getGlobalResource(filename, config.sass);
|
|
78
|
+
const globalResource = getGlobalResource(filename, config.sass || {});
|
|
59
79
|
// sass tranform config
|
|
60
|
-
const additionalData = utils_1.getAdditionalData(src, config.additionalData);
|
|
61
|
-
return utils_1.insertAfter(globalResource, additionalData);
|
|
80
|
+
const additionalData = (0, utils_1.getAdditionalData)(src, config.additionalData);
|
|
81
|
+
return (0, utils_1.insertAfter)(globalResource, additionalData);
|
|
62
82
|
}
|
|
63
83
|
function renderToCSS(src, filename, options, transformOptions) {
|
|
64
84
|
const defaultOpts = {
|
|
@@ -70,24 +90,24 @@ function renderToCSS(src, filename, options, transformOptions) {
|
|
|
70
90
|
// this.options contains this options hash, this.callback contains the node-style callback
|
|
71
91
|
let basedir = '';
|
|
72
92
|
let defaultExt = '';
|
|
73
|
-
if (
|
|
74
|
-
({ dir: basedir, ext: defaultExt } =
|
|
93
|
+
if (path.isAbsolute(prev)) {
|
|
94
|
+
({ dir: basedir, ext: defaultExt } = path.parse(prev));
|
|
75
95
|
}
|
|
76
96
|
else {
|
|
77
|
-
({ dir: basedir, ext: defaultExt } =
|
|
97
|
+
({ dir: basedir, ext: defaultExt } = path.parse(path.resolve(process.cwd(), filename)));
|
|
78
98
|
}
|
|
79
99
|
// 外部 sass importer 配置
|
|
80
100
|
if (typeof options.importer === 'function') {
|
|
81
101
|
({ file: url } = options.importer(params));
|
|
82
102
|
}
|
|
83
103
|
try {
|
|
84
|
-
const file = utils_1.resolveStyle(url, {
|
|
104
|
+
const file = (0, utils_1.resolveStyle)(url, {
|
|
85
105
|
basedir,
|
|
86
106
|
defaultExt,
|
|
87
107
|
alias: options.alias,
|
|
88
108
|
platform: transformOptions.platform
|
|
89
109
|
});
|
|
90
|
-
const contents =
|
|
110
|
+
const contents = fs.readFileSync(file, 'utf8');
|
|
91
111
|
return { file, contents };
|
|
92
112
|
}
|
|
93
113
|
catch (err) {
|
|
@@ -109,7 +129,7 @@ function renderToCSS(src, filename, options, transformOptions) {
|
|
|
109
129
|
}
|
|
110
130
|
function transform(src, filename, config, transformOptions) {
|
|
111
131
|
const additionalData = combineResource(src, filename, config);
|
|
112
|
-
let data = utils_1.insertBefore(src, additionalData);
|
|
132
|
+
let data = (0, utils_1.insertBefore)(src, additionalData);
|
|
113
133
|
if (!data) {
|
|
114
134
|
data = `\n${data}`; // fix empty file error. reference https://github.com/sass/node-sass/blob/91c40a0bf0a3923ab9f91b82dcd479c25486235a/lib/index.js#L430
|
|
115
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sass.js","sourceRoot":"","sources":["../../src/transforms/sass.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sass.js","sourceRoot":"","sources":["../../src/transforms/sass.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAI5B,oCAAqF;AAErF;;GAEG;AACH,SAAS,qBAAqB;IAC5B,IAAI,WAAW,GAAG,WAAW,CAAA;IAE7B,IAAI;QACF,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC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AAO,CAAC,MAAM,CAAC,CAAA;aAChB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAwB,SAAS,CAC/B,GAAW,EACX,QAAgB,EAChB,MAAc,EACd,gBAAkC;IAElC,MAAM,cAAc,GAAG,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC7D,IAAI,IAAI,GAAG,IAAA,oBAAY,EAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAE5C,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,GAAG,KAAK,IAAI,EAAE,CAAA,CAAC,oIAAoI;KACxJ;IAED,OAAO,WAAW,CAChB,IAAI,EACJ,QAAQ,kBAEN,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,GAAG,QAAQ,MAAM,EAC1B,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,MAAM,CAAC,KAAK,IAChB,MAAM,CAAC,OAAO,GAEnB,gBAAgB,CACjB,CAAC,IAAI,CAAC,CAAC,MAAoB,EAAE,EAAE;QAC9B,OAAO,gCAAK,MAAM,KAAE,cAAc,GAA4B,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AA3BD,4BA2BC"}
|
|
@@ -21,7 +21,7 @@ exports.defaultOptions = {
|
|
|
21
21
|
};
|
|
22
22
|
function renderToCSS(src, filename, options = {}) {
|
|
23
23
|
const stylusOptions = Object.assign({ filename }, options);
|
|
24
|
-
const styl = stylus_1.default(src, stylusOptions);
|
|
24
|
+
const styl = (0, stylus_1.default)(src, stylusOptions);
|
|
25
25
|
styl.set('sourcemap', {
|
|
26
26
|
comment: true,
|
|
27
27
|
sourceRoot: '.',
|
|
@@ -97,8 +97,8 @@ function renderToCSS(src, filename, options = {}) {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
function transform(src, filename, config) {
|
|
100
|
-
const additionalData = utils_1.getAdditionalData(src, config.additionalData);
|
|
101
|
-
const data = utils_1.insertBefore(src, additionalData);
|
|
100
|
+
const additionalData = (0, utils_1.getAdditionalData)(src, config.additionalData);
|
|
101
|
+
const data = (0, utils_1.insertBefore)(src, additionalData);
|
|
102
102
|
return renderToCSS(data, filename, config.options).then((result) => {
|
|
103
103
|
return Object.assign(Object.assign({}, result), { additionalData });
|
|
104
104
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylus.js","sourceRoot":"","sources":["../../src/transforms/stylus.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;
|
|
1
|
+
{"version":3,"file":"stylus.js","sourceRoot":"","sources":["../../src/transforms/stylus.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAG3B,oCAA0D;AAE1D,MAAM,SAAS;CAAI;AAsGN,QAAA,cAAc,GAAG;IAC5B,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,KAAK;IACjB,kCAAkC;IAClC,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,KAAK;CACpB,CAAA;AAED,SAAS,WAAW,CAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAmB;IAChE,MAAM,aAAa,mBAAK,QAAQ,IAAK,OAAO,CAAE,CAAA;IAC9C,MAAM,IAAI,GAAG,IAAA,gBAAM,EAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAEvC,IAAI,CAAC,GAAG,CACN,WAAW,EACX;QACE,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,GAAG;KACd,CACF,CAAA;IAED,iCAAiC;IACjC,IAAI,aAAa,CAAC,UAAU,EAAE;QAC5B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;KAC9B;IAED,IAAI,aAAa,CAAC,YAAY,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,C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AA4B,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AAXD,4BAWC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.getAdditionalData = exports.normalizeSourceMap = exports.normalizePath = exports.resolveStyle = exports.findVariant = exports.insertAfter = exports.insertBefore = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
30
|
const helper_1 = require("@tarojs/helper");
|
|
10
|
-
const
|
|
31
|
+
const fs = __importStar(require("fs"));
|
|
32
|
+
const path = __importStar(require("path"));
|
|
33
|
+
const resolve = __importStar(require("resolve"));
|
|
11
34
|
const node_modules_paths_1 = __importDefault(require("resolve/lib/node-modules-paths"));
|
|
12
35
|
function insertBefore(source, additional) {
|
|
13
36
|
if (!source && !additional) {
|
|
@@ -41,11 +64,11 @@ function findVariant(name, extensions, includePaths) {
|
|
|
41
64
|
const includePath = includePaths[i];
|
|
42
65
|
// try to find the file iterating through the extensions, in order.
|
|
43
66
|
const foundExtention = extensions.find(extension => {
|
|
44
|
-
const fname =
|
|
45
|
-
return
|
|
67
|
+
const fname = path.join(includePath, name + extension);
|
|
68
|
+
return fs.existsSync(fname);
|
|
46
69
|
});
|
|
47
70
|
if (foundExtention) {
|
|
48
|
-
return
|
|
71
|
+
return path.join(includePath, name + foundExtention);
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
74
|
return '';
|
|
@@ -57,15 +80,15 @@ exports.findVariant = findVariant;
|
|
|
57
80
|
* @param opts { basedir, platform, paths }
|
|
58
81
|
*/
|
|
59
82
|
function resolveStyle(id, opts) {
|
|
60
|
-
const { basedir, platform, paths = [], alias = {}, defaultExt = '', logLevel = "error" /* ERROR */ } = opts;
|
|
83
|
+
const { basedir, platform, paths = [], alias = {}, defaultExt = '', logLevel = "error" /* LogLevelEnum.ERROR */ } = opts;
|
|
61
84
|
id = id.trim();
|
|
62
85
|
Object.keys(alias).forEach(key => {
|
|
63
86
|
if (id.startsWith(key)) {
|
|
64
87
|
id = id.replace(key, alias[key]);
|
|
65
88
|
}
|
|
66
89
|
});
|
|
67
|
-
const { dir, name, ext: idExt } =
|
|
68
|
-
const incPaths = [
|
|
90
|
+
const { dir, name, ext: idExt } = path.parse(id);
|
|
91
|
+
const incPaths = [path.resolve(basedir, dir)].concat(paths);
|
|
69
92
|
const ext = idExt || defaultExt;
|
|
70
93
|
const extensions = [
|
|
71
94
|
// add the platform specific extension, first in the array to take precedence
|
|
@@ -73,7 +96,7 @@ function resolveStyle(id, opts) {
|
|
|
73
96
|
'.rn' + ext,
|
|
74
97
|
ext
|
|
75
98
|
];
|
|
76
|
-
let file;
|
|
99
|
+
let file = '';
|
|
77
100
|
let isNodeModulesPath = false;
|
|
78
101
|
try {
|
|
79
102
|
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(id)) {
|
|
@@ -83,7 +106,7 @@ function resolveStyle(id, opts) {
|
|
|
83
106
|
// lookup node_modules file
|
|
84
107
|
isNodeModulesPath = true;
|
|
85
108
|
// like `@import 'taro-ui/dist/base.css';` or `@import '~taro-ui/dist/base.css';`
|
|
86
|
-
file =
|
|
109
|
+
file = resolve.sync(path.join(dir, name).replace(/^~/, ''), { basedir, extensions });
|
|
87
110
|
}
|
|
88
111
|
}
|
|
89
112
|
catch (error) {
|
|
@@ -91,7 +114,7 @@ function resolveStyle(id, opts) {
|
|
|
91
114
|
if (!file) {
|
|
92
115
|
let includePaths = incPaths;
|
|
93
116
|
if (isNodeModulesPath) {
|
|
94
|
-
includePaths = node_modules_paths_1.default(basedir, { extensions }, id);
|
|
117
|
+
includePaths = (0, node_modules_paths_1.default)(basedir, { extensions }, id);
|
|
95
118
|
}
|
|
96
119
|
const levelMessage = `
|
|
97
120
|
样式文件没有找到,请检查文件路径: ${id}
|
|
@@ -99,11 +122,11 @@ function resolveStyle(id, opts) {
|
|
|
99
122
|
${includePaths.join(',\n ')}
|
|
100
123
|
]
|
|
101
124
|
`;
|
|
102
|
-
if (logLevel === "error" /* ERROR */) {
|
|
125
|
+
if (logLevel === "error" /* LogLevelEnum.ERROR */) {
|
|
103
126
|
throw new Error(levelMessage);
|
|
104
127
|
}
|
|
105
|
-
if (logLevel === "warning" /* WARNING */) {
|
|
106
|
-
helper_1.printLog("warning" /* WARNING */, levelMessage);
|
|
128
|
+
if (logLevel === "warning" /* LogLevelEnum.WARNING */) {
|
|
129
|
+
(0, helper_1.printLog)("warning" /* processTypeEnum.WARNING */, levelMessage);
|
|
107
130
|
return id;
|
|
108
131
|
}
|
|
109
132
|
}
|
|
@@ -114,7 +137,7 @@ exports.resolveStyle = resolveStyle;
|
|
|
114
137
|
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
|
|
115
138
|
const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i;
|
|
116
139
|
function normalizePath(file) {
|
|
117
|
-
return
|
|
140
|
+
return path.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
|
118
141
|
}
|
|
119
142
|
exports.normalizePath = normalizePath;
|
|
120
143
|
function getURLType(source) {
|
|
@@ -151,9 +174,9 @@ function normalizeSourceMap(map, resourcePath) {
|
|
|
151
174
|
// Do no touch `scheme-relative` and `absolute` URLs
|
|
152
175
|
if (sourceType === 'path-relative' || sourceType === 'path-absolute') {
|
|
153
176
|
const absoluteSource = sourceType === 'path-relative' && sourceRoot
|
|
154
|
-
?
|
|
177
|
+
? path.resolve(sourceRoot, normalizePath(source))
|
|
155
178
|
: normalizePath(source);
|
|
156
|
-
return
|
|
179
|
+
return path.relative(path.dirname(resourcePath), absoluteSource);
|
|
157
180
|
}
|
|
158
181
|
return source;
|
|
159
182
|
});
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,uCAAwB;AACxB,2CAA4B;AAC5B,iDAAkC;AAClC,wFAA6D;AAI7D,SAAgB,YAAY,CAAE,MAAe,EAAE,UAAmB;IAChE,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE;QAC1B,OAAO,EAAE,CAAA;KACV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AAC,CAAA;KACH;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAzCD,gDAyCC;AACD,WAAW;AAEX,SAAgB,iBAAiB,CAAE,IAAY,EAAE,MAA2C;IAC1F,IAAI,cAAc,GAAG,EAAE,CAAA;IACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,cAAc;YACZ,OAAO,MAAM,KAAK,UAAU;gBAC1B,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;gBACnB,CAAC,CAAC,MAAM,CAAA;KACb;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AATD,8CASC;AAED,kBAAe,EAAE,CAAA"}
|
package/dist/utils/lessImport.js
CHANGED
|
@@ -25,7 +25,7 @@ class Importer extends less_1.default.FileManager {
|
|
|
25
25
|
platform: this.platform,
|
|
26
26
|
defaultExt: '.less'
|
|
27
27
|
};
|
|
28
|
-
const rewriteFilename = index_1.resolveStyle(filename, resolveOpts);
|
|
28
|
+
const rewriteFilename = (0, index_1.resolveStyle)(filename, resolveOpts);
|
|
29
29
|
return super.loadFile(rewriteFilename, currentDirectory, options, environment);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lessImport.js","sourceRoot":"","sources":["../../src/utils/lessImport.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;
|
|
1
|
+
{"version":3,"file":"lessImport.js","sourceRoot":"","sources":["../../src/utils/lessImport.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AAEvB,mCAAsC;AAEtC,MAAM,QAAS,SAAQ,cAAI,CAAC,WAAW;IAIrC,YAAa,GAAG;QACd,KAAK,EAAE,CAAA;QAHT,UAAK,GAA2B,EAAE,CAAA;QAIhC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAA;IACb,CAAC;IAED,YAAY;QACV,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,QAAgB,EAChB,gBAAwB,EACxB,OAAY,EACZ,WAAgB;QAEhB,MAAM,WAAW,GAAG;YAClB,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,OAAO;SACpB,CAAA;QACD,MAAM,eAAe,GAAG,IAAA,oBAAY,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;QAE3D,OAAO,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IAChF,CAAC;CACF;AAED,SAAS,cAAc,CAAE,OAAO;IAC9B,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE;YAC5B,aAAa,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;QACrD,CAAC;QACD,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACtB,CAAA;AACH,CAAC;AAED,kBAAe,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/rn-style-transformer",
|
|
3
|
-
"version": "3.5.0
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "提供Taro RN 统一处理样式文件能力",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"test:ci": "jest --silent --coverage false",
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"dev": "tsc -w",
|
|
11
|
-
"lint": "eslint ."
|
|
12
|
-
},
|
|
13
6
|
"repository": {
|
|
14
7
|
"type": "git",
|
|
15
8
|
"url": "git+https://github.com/NervJS/taro.git"
|
|
@@ -23,25 +16,27 @@
|
|
|
23
16
|
"npm": ">=6.0.0"
|
|
24
17
|
},
|
|
25
18
|
"dependencies": {
|
|
26
|
-
"@tarojs/helper": "3.5.0
|
|
19
|
+
"@tarojs/helper": "3.5.0",
|
|
27
20
|
"fbjs": "^2.0.0",
|
|
28
21
|
"less": "^3.12.2",
|
|
29
|
-
"postcss": "^
|
|
22
|
+
"postcss": "^8.4.12",
|
|
30
23
|
"postcss-import": "^12.0.1",
|
|
31
|
-
"postcss-pxtransform": "3.5.0
|
|
24
|
+
"postcss-pxtransform": "3.5.0",
|
|
32
25
|
"postcss-reporter": "^6.0.1",
|
|
33
26
|
"prop-types": "^15.7.2",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"stylelint
|
|
37
|
-
"stylelint-taro-rn": "3.5.0
|
|
38
|
-
"
|
|
39
|
-
"
|
|
27
|
+
"resolve": "^1.22.0",
|
|
28
|
+
"sass": "1.50.0",
|
|
29
|
+
"stylelint": "^14.9.1",
|
|
30
|
+
"stylelint-config-taro-rn": "3.5.0",
|
|
31
|
+
"stylelint-taro-rn": "3.5.0",
|
|
32
|
+
"stylus": "^0.55.0",
|
|
33
|
+
"taro-css-to-react-native": "3.5.0"
|
|
40
34
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"test:ci": "jest --silent --coverage false",
|
|
38
|
+
"build": "tsc",
|
|
39
|
+
"dev": "tsc -w",
|
|
40
|
+
"lint": "eslint ."
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import path from 'path'
|
|
1
|
+
import * as path from 'path'
|
|
2
|
+
|
|
2
3
|
// import semver from 'semver'
|
|
3
4
|
// import reactNativePKG from 'react-native/package.json'
|
|
4
5
|
import StyleTransform from './transforms'
|
|
@@ -14,7 +15,7 @@ const upstreamTransformer = require('metro-react-native-babel-transformer')
|
|
|
14
15
|
const getSingleStyleTransform = styleTransformIns()
|
|
15
16
|
|
|
16
17
|
function styleTransformIns () {
|
|
17
|
-
let styleTransform = null
|
|
18
|
+
let styleTransform: StyleTransform | null = null
|
|
18
19
|
return function (config) {
|
|
19
20
|
// 初始化 config
|
|
20
21
|
if (!styleTransform) {
|
|
@@ -41,3 +42,17 @@ export async function transform (src: string, filename: string, options) {
|
|
|
41
42
|
}
|
|
42
43
|
return upstreamTransformer.transform({ src, filename, options })
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
export function rollupTransform (options) {
|
|
47
|
+
return {
|
|
48
|
+
name: 'rn-style-transformer', // this name will show up in warnings and errors
|
|
49
|
+
async transform (src, filename) {
|
|
50
|
+
const ext = path.extname(filename)
|
|
51
|
+
if (RN_CSS_EXT.includes(ext)) {
|
|
52
|
+
const styleTransform = getSingleStyleTransform((options as any).config)
|
|
53
|
+
const code = await styleTransform.transform(src, filename, options)
|
|
54
|
+
return { code }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|