weapp-tailwindcss 4.2.2-alpha.1 → 4.2.2

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.
@@ -65,6 +65,7 @@ function transformUVue(code, id, jsHandler, runtimeSet) {
65
65
  }
66
66
  return {
67
67
  code: ms.toString(),
68
+ // @ts-ignore
68
69
  get map() {
69
70
  return ms.generateMap();
70
71
  }
@@ -96,13 +97,46 @@ function parseVueRequest(id) {
96
97
  };
97
98
  }
98
99
 
99
- // src/bundlers/vite/index.ts
100
- var debug = _chunkLSSLYD6Bjs.createDebug.call(void 0, );
100
+ // src/bundlers/vite/utils.ts
101
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
102
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
103
+ function slash(p) {
104
+ return p.replace(/\\/g, "/");
105
+ }
106
+ var isWindows = _process2.default.platform === "win32";
101
107
  var cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
102
108
  var cssLangRE = new RegExp(cssLangs);
103
109
  function isCSSRequest(request) {
104
110
  return cssLangRE.test(request);
105
111
  }
112
+ function normalizePath(id) {
113
+ return _path2.default.posix.normalize(isWindows ? slash(id) : id);
114
+ }
115
+ var postfixRE = /[?#].*$/;
116
+ function cleanUrl(url) {
117
+ return url.replace(postfixRE, "");
118
+ }
119
+ async function formatPostcssSourceMap(rawMap, file) {
120
+ const inputFileDir = _path2.default.dirname(file);
121
+ const sources = rawMap.sources.map((source) => {
122
+ const cleanSource = cleanUrl(decodeURIComponent(source));
123
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) {
124
+ return `\0${cleanSource}`;
125
+ }
126
+ return normalizePath(_path2.default.resolve(inputFileDir, cleanSource));
127
+ });
128
+ return {
129
+ file,
130
+ mappings: rawMap.mappings,
131
+ names: rawMap.names,
132
+ sources,
133
+ sourcesContent: rawMap.sourcesContent,
134
+ version: rawMap.version
135
+ };
136
+ }
137
+
138
+ // src/bundlers/vite/index.ts
139
+ var debug = _chunkLSSLYD6Bjs.createDebug.call(void 0, );
106
140
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
107
141
  const opts = _chunkPLEG4SRNjs.getCompilerContext.call(void 0, options);
108
142
  const {
@@ -323,53 +357,48 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
323
357
  }
324
358
  ];
325
359
  if (uniAppX) {
326
- plugins.push(
327
- {
328
- name: "weapp-tailwindcss:uni-app-x:css:pre",
329
- enforce: "pre",
330
- async transform(code, id) {
331
- const { query } = parseVueRequest(id);
332
- if (isCSSRequest(id) || query.vue && query.type === "style") {
333
- const { css, map } = await styleHandler(code, {
334
- isMainChunk: mainCssChunkMatcher(id, appType),
335
- postcssOptions: {
336
- options: {
337
- from: id,
338
- map: true
339
- }
340
- }
341
- });
342
- return {
343
- code: css,
344
- map: _optionalChain([map, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])
345
- };
346
- }
347
- }
348
- }
349
- );
350
- plugins.push(
351
- {
352
- name: "weapp-tailwindcss:uni-app-x:css",
353
- async transform(code, id) {
354
- const { query } = parseVueRequest(id);
355
- if (isCSSRequest(id) || query.vue && query.type === "style") {
356
- const { css, map } = await styleHandler(code, {
357
- isMainChunk: mainCssChunkMatcher(id, appType),
358
- postcssOptions: {
359
- options: {
360
- from: id,
361
- map: true
360
+ ;
361
+ [void 0, "pre"].forEach((enforce) => {
362
+ plugins.push(
363
+ {
364
+ name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
365
+ enforce,
366
+ async transform(code, id) {
367
+ const { query } = parseVueRequest(id);
368
+ if (isCSSRequest(id) || query.vue && query.type === "style") {
369
+ const postcssResult = await styleHandler(code, {
370
+ isMainChunk: mainCssChunkMatcher(id, appType),
371
+ postcssOptions: {
372
+ options: {
373
+ from: id,
374
+ map: {
375
+ inline: false,
376
+ annotation: false,
377
+ // postcss may return virtual files
378
+ // we cannot obtain content of them, so this needs to be enabled
379
+ sourcesContent: true
380
+ // when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
381
+ // prev: preprocessorMap,
382
+ }
383
+ }
362
384
  }
363
- }
364
- });
365
- return {
366
- code: css,
367
- map: _optionalChain([map, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()])
368
- };
385
+ });
386
+ const rawPostcssMap = postcssResult.map.toJSON();
387
+ const postcssMap = await formatPostcssSourceMap(
388
+ // version property of rawPostcssMap is declared as string
389
+ // but actually it is a number
390
+ rawPostcssMap,
391
+ cleanUrl(id)
392
+ );
393
+ return {
394
+ code: postcssResult.css,
395
+ map: postcssMap
396
+ };
397
+ }
369
398
  }
370
399
  }
371
- }
372
- );
400
+ );
401
+ });
373
402
  plugins.push(
374
403
  {
375
404
  name: "weapp-tailwindcss:uni-app-x:nvue",
@@ -391,6 +420,4 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
391
420
 
392
421
 
393
422
 
394
-
395
-
396
- exports.cssLangRE = cssLangRE; exports.isCSSRequest = isCSSRequest; exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;
423
+ exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;
@@ -65,6 +65,7 @@ function transformUVue(code, id, jsHandler, runtimeSet) {
65
65
  }
66
66
  return {
67
67
  code: ms.toString(),
68
+ // @ts-ignore
68
69
  get map() {
69
70
  return ms.generateMap();
70
71
  }
@@ -96,13 +97,46 @@ function parseVueRequest(id) {
96
97
  };
97
98
  }
98
99
 
99
- // src/bundlers/vite/index.ts
100
- var debug = createDebug();
100
+ // src/bundlers/vite/utils.ts
101
+ import path from "path";
102
+ import process from "process";
103
+ function slash(p) {
104
+ return p.replace(/\\/g, "/");
105
+ }
106
+ var isWindows = process.platform === "win32";
101
107
  var cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
102
108
  var cssLangRE = new RegExp(cssLangs);
103
109
  function isCSSRequest(request) {
104
110
  return cssLangRE.test(request);
105
111
  }
112
+ function normalizePath(id) {
113
+ return path.posix.normalize(isWindows ? slash(id) : id);
114
+ }
115
+ var postfixRE = /[?#].*$/;
116
+ function cleanUrl(url) {
117
+ return url.replace(postfixRE, "");
118
+ }
119
+ async function formatPostcssSourceMap(rawMap, file) {
120
+ const inputFileDir = path.dirname(file);
121
+ const sources = rawMap.sources.map((source) => {
122
+ const cleanSource = cleanUrl(decodeURIComponent(source));
123
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) {
124
+ return `\0${cleanSource}`;
125
+ }
126
+ return normalizePath(path.resolve(inputFileDir, cleanSource));
127
+ });
128
+ return {
129
+ file,
130
+ mappings: rawMap.mappings,
131
+ names: rawMap.names,
132
+ sources,
133
+ sourcesContent: rawMap.sourcesContent,
134
+ version: rawMap.version
135
+ };
136
+ }
137
+
138
+ // src/bundlers/vite/index.ts
139
+ var debug = createDebug();
106
140
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
107
141
  const opts = getCompilerContext(options);
108
142
  const {
@@ -323,53 +357,48 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
323
357
  }
324
358
  ];
325
359
  if (uniAppX) {
326
- plugins.push(
327
- {
328
- name: "weapp-tailwindcss:uni-app-x:css:pre",
329
- enforce: "pre",
330
- async transform(code, id) {
331
- const { query } = parseVueRequest(id);
332
- if (isCSSRequest(id) || query.vue && query.type === "style") {
333
- const { css, map } = await styleHandler(code, {
334
- isMainChunk: mainCssChunkMatcher(id, appType),
335
- postcssOptions: {
336
- options: {
337
- from: id,
338
- map: true
339
- }
340
- }
341
- });
342
- return {
343
- code: css,
344
- map: map?.toString()
345
- };
346
- }
347
- }
348
- }
349
- );
350
- plugins.push(
351
- {
352
- name: "weapp-tailwindcss:uni-app-x:css",
353
- async transform(code, id) {
354
- const { query } = parseVueRequest(id);
355
- if (isCSSRequest(id) || query.vue && query.type === "style") {
356
- const { css, map } = await styleHandler(code, {
357
- isMainChunk: mainCssChunkMatcher(id, appType),
358
- postcssOptions: {
359
- options: {
360
- from: id,
361
- map: true
360
+ ;
361
+ [void 0, "pre"].forEach((enforce) => {
362
+ plugins.push(
363
+ {
364
+ name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
365
+ enforce,
366
+ async transform(code, id) {
367
+ const { query } = parseVueRequest(id);
368
+ if (isCSSRequest(id) || query.vue && query.type === "style") {
369
+ const postcssResult = await styleHandler(code, {
370
+ isMainChunk: mainCssChunkMatcher(id, appType),
371
+ postcssOptions: {
372
+ options: {
373
+ from: id,
374
+ map: {
375
+ inline: false,
376
+ annotation: false,
377
+ // postcss may return virtual files
378
+ // we cannot obtain content of them, so this needs to be enabled
379
+ sourcesContent: true
380
+ // when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
381
+ // prev: preprocessorMap,
382
+ }
383
+ }
362
384
  }
363
- }
364
- });
365
- return {
366
- code: css,
367
- map: map?.toString()
368
- };
385
+ });
386
+ const rawPostcssMap = postcssResult.map.toJSON();
387
+ const postcssMap = await formatPostcssSourceMap(
388
+ // version property of rawPostcssMap is declared as string
389
+ // but actually it is a number
390
+ rawPostcssMap,
391
+ cleanUrl(id)
392
+ );
393
+ return {
394
+ code: postcssResult.css,
395
+ map: postcssMap
396
+ };
397
+ }
369
398
  }
370
399
  }
371
- }
372
- );
400
+ );
401
+ });
373
402
  plugins.push(
374
403
  {
375
404
  name: "weapp-tailwindcss:uni-app-x:nvue",
@@ -390,7 +419,5 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
390
419
  }
391
420
 
392
421
  export {
393
- cssLangRE,
394
- isCSSRequest,
395
422
  UnifiedViteWeappTailwindcssPlugin
396
423
  };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createPlugins } from './gulp.mjs';
2
2
  export { AppType, CreateJsHandlerOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalCssSelectorReplacerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, UserDefinedOptions } from './types.mjs';
3
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest } from './vite.mjs';
3
+ export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
4
4
  export { UnifiedWebpackPluginV5 } from './webpack.mjs';
5
5
  export { CssPreflightOptions, IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
6
6
  export { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createPlugins } from './gulp.js';
2
2
  export { AppType, CreateJsHandlerOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalCssSelectorReplacerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, UserDefinedOptions } from './types.js';
3
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest } from './vite.js';
3
+ export { UnifiedViteWeappTailwindcssPlugin } from './vite.js';
4
4
  export { UnifiedWebpackPluginV5 } from './webpack.js';
5
5
  export { CssPreflightOptions, IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
6
6
  export { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
package/dist/index.js CHANGED
@@ -7,9 +7,7 @@ var _chunkZK5OYQKNjs = require('./chunk-ZK5OYQKN.js');
7
7
  var _chunkXPJSMUIZjs = require('./chunk-XPJSMUIZ.js');
8
8
 
9
9
 
10
-
11
-
12
- var _chunkJJBOP2VIjs = require('./chunk-JJBOP2VI.js');
10
+ var _chunk6DZTQZYIjs = require('./chunk-6DZTQZYI.js');
13
11
  require('./chunk-LSSLYD6B.js');
14
12
  require('./chunk-OGROHM4L.js');
15
13
  require('./chunk-PLEG4SRN.js');
@@ -21,6 +19,4 @@ require('./chunk-U5U4QBHD.js');
21
19
 
22
20
 
23
21
 
24
-
25
-
26
- exports.UnifiedViteWeappTailwindcssPlugin = _chunkJJBOP2VIjs.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunkZK5OYQKNjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkXPJSMUIZjs.createPlugins; exports.cssLangRE = _chunkJJBOP2VIjs.cssLangRE; exports.isCSSRequest = _chunkJJBOP2VIjs.isCSSRequest;
22
+ exports.UnifiedViteWeappTailwindcssPlugin = _chunk6DZTQZYIjs.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunkZK5OYQKNjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkXPJSMUIZjs.createPlugins;
package/dist/index.mjs CHANGED
@@ -6,10 +6,8 @@ import {
6
6
  createPlugins
7
7
  } from "./chunk-RF63Y6B4.mjs";
8
8
  import {
9
- UnifiedViteWeappTailwindcssPlugin,
10
- cssLangRE,
11
- isCSSRequest
12
- } from "./chunk-DHRJQIWW.mjs";
9
+ UnifiedViteWeappTailwindcssPlugin
10
+ } from "./chunk-S75INQRJ.mjs";
13
11
  import "./chunk-3AUX4FGE.mjs";
14
12
  import "./chunk-CMUA5KCO.mjs";
15
13
  import "./chunk-FOPIY67W.mjs";
@@ -20,7 +18,5 @@ import "./chunk-QKNCXAGV.mjs";
20
18
  export {
21
19
  UnifiedViteWeappTailwindcssPlugin,
22
20
  UnifiedWebpackPluginV5,
23
- createPlugins,
24
- cssLangRE,
25
- isCSSRequest
21
+ createPlugins
26
22
  };
package/dist/vite.d.mts CHANGED
@@ -11,8 +11,6 @@ import 'webpack';
11
11
  import 'lru-cache';
12
12
  import 'postcss-preset-env';
13
13
 
14
- declare const cssLangRE: RegExp;
15
- declare function isCSSRequest(request: string): boolean;
16
14
  /**
17
15
  * @name UnifiedViteWeappTailwindcssPlugin
18
16
  * @description uni-app vite vue3 版本插件
@@ -20,4 +18,4 @@ declare function isCSSRequest(request: string): boolean;
20
18
  */
21
19
  declare function UnifiedViteWeappTailwindcssPlugin(options?: UserDefinedOptions): Plugin[] | undefined;
22
20
 
23
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest };
21
+ export { UnifiedViteWeappTailwindcssPlugin };
package/dist/vite.d.ts CHANGED
@@ -11,8 +11,6 @@ import 'webpack';
11
11
  import 'lru-cache';
12
12
  import 'postcss-preset-env';
13
13
 
14
- declare const cssLangRE: RegExp;
15
- declare function isCSSRequest(request: string): boolean;
16
14
  /**
17
15
  * @name UnifiedViteWeappTailwindcssPlugin
18
16
  * @description uni-app vite vue3 版本插件
@@ -20,4 +18,4 @@ declare function isCSSRequest(request: string): boolean;
20
18
  */
21
19
  declare function UnifiedViteWeappTailwindcssPlugin(options?: UserDefinedOptions): Plugin[] | undefined;
22
20
 
23
- export { UnifiedViteWeappTailwindcssPlugin, cssLangRE, isCSSRequest };
21
+ export { UnifiedViteWeappTailwindcssPlugin };
package/dist/vite.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
-
4
-
5
- var _chunkJJBOP2VIjs = require('./chunk-JJBOP2VI.js');
3
+ var _chunk6DZTQZYIjs = require('./chunk-6DZTQZYI.js');
6
4
  require('./chunk-LSSLYD6B.js');
7
5
  require('./chunk-OGROHM4L.js');
8
6
  require('./chunk-PLEG4SRN.js');
@@ -12,6 +10,4 @@ require('./chunk-O335YLYH.js');
12
10
  require('./chunk-U5U4QBHD.js');
13
11
 
14
12
 
15
-
16
-
17
- exports.UnifiedViteWeappTailwindcssPlugin = _chunkJJBOP2VIjs.UnifiedViteWeappTailwindcssPlugin; exports.cssLangRE = _chunkJJBOP2VIjs.cssLangRE; exports.isCSSRequest = _chunkJJBOP2VIjs.isCSSRequest;
13
+ exports.UnifiedViteWeappTailwindcssPlugin = _chunk6DZTQZYIjs.UnifiedViteWeappTailwindcssPlugin;
package/dist/vite.mjs CHANGED
@@ -1,8 +1,6 @@
1
1
  import {
2
- UnifiedViteWeappTailwindcssPlugin,
3
- cssLangRE,
4
- isCSSRequest
5
- } from "./chunk-DHRJQIWW.mjs";
2
+ UnifiedViteWeappTailwindcssPlugin
3
+ } from "./chunk-S75INQRJ.mjs";
6
4
  import "./chunk-3AUX4FGE.mjs";
7
5
  import "./chunk-CMUA5KCO.mjs";
8
6
  import "./chunk-FOPIY67W.mjs";
@@ -11,7 +9,5 @@ import "./chunk-ABB7LXDE.mjs";
11
9
  import "./chunk-JXBLHLFR.mjs";
12
10
  import "./chunk-QKNCXAGV.mjs";
13
11
  export {
14
- UnifiedViteWeappTailwindcssPlugin,
15
- cssLangRE,
16
- isCSSRequest
12
+ UnifiedViteWeappTailwindcssPlugin
17
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "4.2.2-alpha.1",
3
+ "version": "4.2.2",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -178,7 +178,7 @@
178
178
  "@weapp-tailwindcss/init": "1.0.3",
179
179
  "@weapp-tailwindcss/logger": "1.0.2",
180
180
  "@weapp-tailwindcss/mangle": "1.0.5",
181
- "@weapp-tailwindcss/postcss": "1.0.18",
181
+ "@weapp-tailwindcss/postcss": "1.0.19",
182
182
  "@weapp-tailwindcss/shared": "1.0.3"
183
183
  },
184
184
  "scripts": {