@plugin-light/shared 1.0.2 → 1.0.3

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/lib/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { findDependencies, } from './find-dependencies';
11
11
  export { checkH5, } from './h5';
12
12
  export { getLoaderFile, getLoaderProdFile, } from './loader-file';
13
13
  export { recordLoaderLog, saveLoaderLog, } from './loader-log';
14
+ export { shouldUseLoader, } from './loader-options';
14
15
  export { getWxmlAndWxssPostfix, } from './platform';
15
16
  export { getProjectName, getSubProjectName, } from './project-name';
16
17
  export { revertManifest, updateManifest, } from './replace-manifest';
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ var fs = require('fs');
6
6
  var path = require('path');
7
7
  var tComm = require('t-comm');
8
8
  var path$1 = require('node:path');
9
+ var loaderUtils = require('loader-utils');
9
10
  var fs$1 = require('node:fs');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -388,6 +389,17 @@ function recordLoaderLog(file, content) {
388
389
  global[LOG_KEY][file].push(content);
389
390
  }
390
391
 
392
+ function shouldUseLoader(defaultPlatforms = []) {
393
+ const options = loaderUtils.getOptions(this) || {};
394
+ const { platforms = defaultPlatforms } = options;
395
+ const platform = process.env.UNI_PLATFORM || '';
396
+ if (platforms === ALL_PLATFORM
397
+ || platforms.indexOf(ALL_PLATFORM) > -1) {
398
+ return true;
399
+ }
400
+ return platforms.includes(platform);
401
+ }
402
+
391
403
  function getWxmlAndWxssPostfix() {
392
404
  const map = Object.keys(PLATFORM_MAP).reduce((acc, item) => {
393
405
  acc[PLATFORM_MAP[item]] = item;
@@ -924,6 +936,7 @@ exports.revertManifest = revertManifest;
924
936
  exports.saveJsonToLog = saveJsonToLog;
925
937
  exports.saveLoaderLog = saveLoaderLog;
926
938
  exports.scssLogger = scssLogger;
939
+ exports.shouldUseLoader = shouldUseLoader;
927
940
  exports.updateAssetSource = updateAssetSource;
928
941
  exports.updateManifest = updateManifest;
929
942
  exports.vLazyCore = vLazyCore;
@@ -0,0 +1 @@
1
+ export declare function shouldUseLoader(this: any, defaultPlatforms?: Array<string>): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plugin-light/shared",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "homepage": "https://novlan1.github.io/docs/plugin-light/zh/plugin-light-shared.html",
5
5
  "bugs": {
6
6
  "url": "https://github.com/novlan1/plugin-light/issues"
@@ -16,7 +16,8 @@
16
16
  "lib/"
17
17
  ],
18
18
  "dependencies": {
19
- "t-comm": "^3.0.3"
19
+ "loader-utils": "^2.0.4",
20
+ "t-comm": "^3.0.22"
20
21
  },
21
22
  "scripts": {
22
23
  "build": "rm -rf lib && rollup -c",