@modern-js/plugin-data-loader 2.56.1 → 2.57.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.
@@ -28,10 +28,10 @@ async function loader(source) {
28
28
  var _this__compiler;
29
29
  this.cacheable();
30
30
  const target = (_this__compiler = this._compiler) === null || _this__compiler === void 0 ? void 0 : _this__compiler.options.target;
31
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
32
- return source;
33
- }
34
- if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
31
+ const shouldSkip = (compileTarget) => {
32
+ return target === compileTarget || Array.isArray(target) && target.includes(compileTarget);
33
+ };
34
+ if (shouldSkip("node") || shouldSkip("webworker") || shouldSkip("async-node")) {
35
35
  return source;
36
36
  }
37
37
  const { resourceQuery } = this;
@@ -42,7 +42,7 @@ async function loader(source) {
42
42
  }
43
43
  return pre;
44
44
  }, {});
45
- if (!options.loaderId) {
45
+ if (!options.loaderId || options.retain) {
46
46
  return source;
47
47
  }
48
48
  if (options.clientData) {
@@ -9,19 +9,16 @@ function loader(source) {
9
9
  }
10
10
  function _loader() {
11
11
  _loader = _async_to_generator(function(source) {
12
- var _this__compiler, target, resourceQuery, options, readFile, clientDataPath, clientDataContent, error, code;
12
+ var _this__compiler, target, shouldSkip, resourceQuery, options, readFile, clientDataPath, clientDataContent, error, code;
13
13
  return _ts_generator(this, function(_state) {
14
14
  switch (_state.label) {
15
15
  case 0:
16
16
  this.cacheable();
17
17
  target = (_this__compiler = this._compiler) === null || _this__compiler === void 0 ? void 0 : _this__compiler.options.target;
18
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
19
- return [
20
- 2,
21
- source
22
- ];
23
- }
24
- if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
18
+ shouldSkip = function(compileTarget) {
19
+ return target === compileTarget || Array.isArray(target) && target.includes(compileTarget);
20
+ };
21
+ if (shouldSkip("node") || shouldSkip("webworker") || shouldSkip("async-node")) {
25
22
  return [
26
23
  2,
27
24
  source
@@ -35,7 +32,7 @@ function _loader() {
35
32
  }
36
33
  return pre;
37
34
  }, {});
38
- if (!options.loaderId) {
35
+ if (!options.loaderId || options.retain) {
39
36
  return [
40
37
  2,
41
38
  source
@@ -5,10 +5,10 @@ async function loader(source) {
5
5
  var _this__compiler;
6
6
  this.cacheable();
7
7
  const target = (_this__compiler = this._compiler) === null || _this__compiler === void 0 ? void 0 : _this__compiler.options.target;
8
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
9
- return source;
10
- }
11
- if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
8
+ const shouldSkip = (compileTarget) => {
9
+ return target === compileTarget || Array.isArray(target) && target.includes(compileTarget);
10
+ };
11
+ if (shouldSkip("node") || shouldSkip("webworker") || shouldSkip("async-node")) {
12
12
  return source;
13
13
  }
14
14
  const { resourceQuery } = this;
@@ -19,7 +19,7 @@ async function loader(source) {
19
19
  }
20
20
  return pre;
21
21
  }, {});
22
- if (!options.loaderId) {
22
+ if (!options.loaderId || options.retain) {
23
23
  return source;
24
24
  }
25
25
  if (options.clientData) {
@@ -7,6 +7,7 @@ type Context = {
7
7
  action: boolean;
8
8
  inline: boolean;
9
9
  routeId: string;
10
+ retain: boolean;
10
11
  };
11
12
  export default function loader(this: LoaderContext<Context>, source: string): Promise<string | Buffer | undefined>;
12
13
  export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.56.1",
18
+ "version": "2.57.0",
19
19
  "engines": {
20
20
  "node": ">=16.2.0"
21
21
  },
@@ -49,8 +49,8 @@
49
49
  "@babel/core": "^7.24.7",
50
50
  "path-to-regexp": "^6.2.0",
51
51
  "@swc/helpers": "0.5.3",
52
- "@modern-js/utils": "2.56.1",
53
- "@modern-js/runtime-utils": "2.56.1"
52
+ "@modern-js/utils": "2.57.0",
53
+ "@modern-js/runtime-utils": "2.57.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/babel__core": "^7.20.5",
@@ -66,11 +66,11 @@
66
66
  "webpack": "^5.93.0",
67
67
  "react": "^18",
68
68
  "react-dom": "^18",
69
- "@modern-js/server-core": "2.56.1",
70
- "@modern-js/types": "2.56.1",
71
- "@scripts/jest-config": "2.56.1",
72
- "@scripts/build": "2.56.1",
73
- "@modern-js/core": "2.56.1"
69
+ "@modern-js/core": "2.57.0",
70
+ "@modern-js/types": "2.57.0",
71
+ "@modern-js/server-core": "2.57.0",
72
+ "@scripts/build": "2.57.0",
73
+ "@scripts/jest-config": "2.57.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": ">=17.0.0"