@modern-js/app-tools 2.64.2 → 2.64.3-alpha.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.
@@ -53,11 +53,12 @@ async function generateBuilder(options, bundlerType) {
53
53
  return builder;
54
54
  }
55
55
  async function applyBuilderPlugins(builder, options) {
56
- const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR } = await import("../shared/builderPlugins/index.js");
56
+ const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderHookPlugin } = await import("../shared/builderPlugins/index.js");
57
57
  builder.addPlugins([
58
58
  builderPluginAdapterBasic(),
59
59
  builderPluginAdapterSSR(options),
60
- builderPluginAdapterHtml(options)
60
+ builderPluginAdapterHtml(options),
61
+ builderHookPlugin(options)
61
62
  ]);
62
63
  builder.addPlugins([
63
64
  (0, import_adapterCopy.builderPluginAdapterCopy)(options)
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var builderHooks_exports = {};
20
+ __export(builderHooks_exports, {
21
+ builderHookPlugin: () => builderHookPlugin
22
+ });
23
+ module.exports = __toCommonJS(builderHooks_exports);
24
+ const builderHookPlugin = (options) => ({
25
+ name: "builder-plugin-support-modern-hooks",
26
+ setup(api) {
27
+ var _internalContext_pluginAPI;
28
+ const _internalContext = options.appContext._internalContext;
29
+ const hooks = (_internalContext_pluginAPI = _internalContext.pluginAPI) === null || _internalContext_pluginAPI === void 0 ? void 0 : _internalContext_pluginAPI.getHooks();
30
+ api.modifyBundlerChain(async (chain, utils) => {
31
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyBundlerChain.call(chain, utils));
32
+ });
33
+ api.modifyRsbuildConfig(async (config, utils) => {
34
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyRsbuildConfig.call(config, utils));
35
+ });
36
+ api.modifyRspackConfig(async (config, utils) => {
37
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyRspackConfig.call(config, utils));
38
+ });
39
+ api.modifyWebpackChain(async (chain, utils) => {
40
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyWebpackChain.call(chain, utils));
41
+ });
42
+ api.modifyWebpackConfig(async (config, utils) => {
43
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyWebpackConfig.call(config, utils));
44
+ });
45
+ }
46
+ });
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ builderHookPlugin
50
+ });
@@ -18,9 +18,11 @@ module.exports = __toCommonJS(builderPlugins_exports);
18
18
  __reExport(builderPlugins_exports, require("./adapterBasic"), module.exports);
19
19
  __reExport(builderPlugins_exports, require("./adapterHtml"), module.exports);
20
20
  __reExport(builderPlugins_exports, require("./adapterSSR"), module.exports);
21
+ __reExport(builderPlugins_exports, require("./builderHooks"), module.exports);
21
22
  // Annotate the CommonJS export names for ESM import in node:
22
23
  0 && (module.exports = {
23
24
  ...require("./adapterBasic"),
24
25
  ...require("./adapterHtml"),
25
- ...require("./adapterSSR")
26
+ ...require("./adapterSSR"),
27
+ ...require("./builderHooks")
26
28
  });
@@ -1,4 +1,5 @@
1
1
  import { pathToFileURL } from 'url';
2
+ import { load as esbuildLoad } from 'esbuild-register/loader';
2
3
  import { createMatchPath } from './utils.mjs';
3
4
 
4
5
  let matchPath;
@@ -17,4 +18,16 @@ export function resolve(specifier, context, defaultResolve) {
17
18
  : defaultResolve(specifier, context);
18
19
  }
19
20
 
20
- export { load } from 'esbuild-register/loader';
21
+ export function load(url, context, defaultLoad) {
22
+ const filePath = new URL(url).pathname;
23
+
24
+ if (url.startsWith('node:')) {
25
+ return defaultLoad(url, context);
26
+ }
27
+
28
+ if (filePath.includes('node_modules')) {
29
+ return defaultLoad(url, context);
30
+ }
31
+
32
+ return esbuildLoad(url, context, defaultLoad);
33
+ }
@@ -1,5 +1,6 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { resolve as tsNodeResolve } from 'ts-node/esm';
3
+ import { load as tsNodeLoad } from 'ts-node/esm';
3
4
  import { createMatchPath } from './utils.mjs';
4
5
 
5
6
  let matchPath;
@@ -18,4 +19,16 @@ export function resolve(specifier, context, defaultResolve) {
18
19
  : tsNodeResolve(specifier, context, defaultResolve);
19
20
  }
20
21
 
21
- export { transformSource, load } from 'ts-node/esm';
22
+ export function load(url, context, defaultLoad) {
23
+ const filePath = new URL(url).pathname;
24
+
25
+ if (url.startsWith('node:')) {
26
+ return defaultLoad(url, context);
27
+ }
28
+
29
+ if (filePath.includes('node_modules')) {
30
+ return defaultLoad(url, context);
31
+ }
32
+
33
+ return tsNodeLoad(url, context, defaultLoad);
34
+ }
@@ -51,7 +51,7 @@ function applyBuilderPlugins(builder, options) {
51
51
  }
52
52
  function _applyBuilderPlugins() {
53
53
  _applyBuilderPlugins = _async_to_generator(function(builder, options) {
54
- var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, normalizedConfig, pluginNodePolyfill;
54
+ var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderHookPlugin, normalizedConfig, pluginNodePolyfill;
55
55
  return _ts_generator(this, function(_state) {
56
56
  switch (_state.label) {
57
57
  case 0:
@@ -60,11 +60,12 @@ function _applyBuilderPlugins() {
60
60
  import("../shared/builderPlugins/index.js")
61
61
  ];
62
62
  case 1:
63
- _ref = _state.sent(), builderPluginAdapterBasic = _ref.builderPluginAdapterBasic, builderPluginAdapterHtml = _ref.builderPluginAdapterHtml, builderPluginAdapterSSR = _ref.builderPluginAdapterSSR;
63
+ _ref = _state.sent(), builderPluginAdapterBasic = _ref.builderPluginAdapterBasic, builderPluginAdapterHtml = _ref.builderPluginAdapterHtml, builderPluginAdapterSSR = _ref.builderPluginAdapterSSR, builderHookPlugin = _ref.builderHookPlugin;
64
64
  builder.addPlugins([
65
65
  builderPluginAdapterBasic(),
66
66
  builderPluginAdapterSSR(options),
67
- builderPluginAdapterHtml(options)
67
+ builderPluginAdapterHtml(options),
68
+ builderHookPlugin(options)
68
69
  ]);
69
70
  builder.addPlugins([
70
71
  builderPluginAdapterCopy(options)
@@ -0,0 +1,120 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
+ var builderHookPlugin = function(options) {
4
+ return {
5
+ name: "builder-plugin-support-modern-hooks",
6
+ setup: function setup(api) {
7
+ var _internalContext_pluginAPI;
8
+ var _internalContext = options.appContext._internalContext;
9
+ var hooks = (_internalContext_pluginAPI = _internalContext.pluginAPI) === null || _internalContext_pluginAPI === void 0 ? void 0 : _internalContext_pluginAPI.getHooks();
10
+ api.modifyBundlerChain(function() {
11
+ var _ref = _async_to_generator(function(chain, utils) {
12
+ return _ts_generator(this, function(_state) {
13
+ switch (_state.label) {
14
+ case 0:
15
+ return [
16
+ 4,
17
+ hooks === null || hooks === void 0 ? void 0 : hooks.modifyBundlerChain.call(chain, utils)
18
+ ];
19
+ case 1:
20
+ _state.sent();
21
+ return [
22
+ 2
23
+ ];
24
+ }
25
+ });
26
+ });
27
+ return function(chain, utils) {
28
+ return _ref.apply(this, arguments);
29
+ };
30
+ }());
31
+ api.modifyRsbuildConfig(function() {
32
+ var _ref = _async_to_generator(function(config, utils) {
33
+ return _ts_generator(this, function(_state) {
34
+ switch (_state.label) {
35
+ case 0:
36
+ return [
37
+ 4,
38
+ hooks === null || hooks === void 0 ? void 0 : hooks.modifyRsbuildConfig.call(config, utils)
39
+ ];
40
+ case 1:
41
+ _state.sent();
42
+ return [
43
+ 2
44
+ ];
45
+ }
46
+ });
47
+ });
48
+ return function(config, utils) {
49
+ return _ref.apply(this, arguments);
50
+ };
51
+ }());
52
+ api.modifyRspackConfig(function() {
53
+ var _ref = _async_to_generator(function(config, utils) {
54
+ return _ts_generator(this, function(_state) {
55
+ switch (_state.label) {
56
+ case 0:
57
+ return [
58
+ 4,
59
+ hooks === null || hooks === void 0 ? void 0 : hooks.modifyRspackConfig.call(config, utils)
60
+ ];
61
+ case 1:
62
+ _state.sent();
63
+ return [
64
+ 2
65
+ ];
66
+ }
67
+ });
68
+ });
69
+ return function(config, utils) {
70
+ return _ref.apply(this, arguments);
71
+ };
72
+ }());
73
+ api.modifyWebpackChain(function() {
74
+ var _ref = _async_to_generator(function(chain, utils) {
75
+ return _ts_generator(this, function(_state) {
76
+ switch (_state.label) {
77
+ case 0:
78
+ return [
79
+ 4,
80
+ hooks === null || hooks === void 0 ? void 0 : hooks.modifyWebpackChain.call(chain, utils)
81
+ ];
82
+ case 1:
83
+ _state.sent();
84
+ return [
85
+ 2
86
+ ];
87
+ }
88
+ });
89
+ });
90
+ return function(chain, utils) {
91
+ return _ref.apply(this, arguments);
92
+ };
93
+ }());
94
+ api.modifyWebpackConfig(function() {
95
+ var _ref = _async_to_generator(function(config, utils) {
96
+ return _ts_generator(this, function(_state) {
97
+ switch (_state.label) {
98
+ case 0:
99
+ return [
100
+ 4,
101
+ hooks === null || hooks === void 0 ? void 0 : hooks.modifyWebpackConfig.call(config, utils)
102
+ ];
103
+ case 1:
104
+ _state.sent();
105
+ return [
106
+ 2
107
+ ];
108
+ }
109
+ });
110
+ });
111
+ return function(config, utils) {
112
+ return _ref.apply(this, arguments);
113
+ };
114
+ }());
115
+ }
116
+ };
117
+ };
118
+ export {
119
+ builderHookPlugin
120
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./adapterBasic";
2
2
  export * from "./adapterHtml";
3
3
  export * from "./adapterSSR";
4
+ export * from "./builderHooks";
@@ -1,4 +1,5 @@
1
1
  import { pathToFileURL } from 'url';
2
+ import { load as esbuildLoad } from 'esbuild-register/loader';
2
3
  import { createMatchPath } from './utils.mjs';
3
4
 
4
5
  let matchPath;
@@ -17,4 +18,16 @@ export function resolve(specifier, context, defaultResolve) {
17
18
  : defaultResolve(specifier, context);
18
19
  }
19
20
 
20
- export { load } from 'esbuild-register/loader';
21
+ export function load(url, context, defaultLoad) {
22
+ const filePath = new URL(url).pathname;
23
+
24
+ if (url.startsWith('node:')) {
25
+ return defaultLoad(url, context);
26
+ }
27
+
28
+ if (filePath.includes('node_modules')) {
29
+ return defaultLoad(url, context);
30
+ }
31
+
32
+ return esbuildLoad(url, context, defaultLoad);
33
+ }
@@ -1,5 +1,6 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { resolve as tsNodeResolve } from 'ts-node/esm';
3
+ import { load as tsNodeLoad } from 'ts-node/esm';
3
4
  import { createMatchPath } from './utils.mjs';
4
5
 
5
6
  let matchPath;
@@ -18,4 +19,16 @@ export function resolve(specifier, context, defaultResolve) {
18
19
  : tsNodeResolve(specifier, context, defaultResolve);
19
20
  }
20
21
 
21
- export { transformSource, load } from 'ts-node/esm';
22
+ export function load(url, context, defaultLoad) {
23
+ const filePath = new URL(url).pathname;
24
+
25
+ if (url.startsWith('node:')) {
26
+ return defaultLoad(url, context);
27
+ }
28
+
29
+ if (filePath.includes('node_modules')) {
30
+ return defaultLoad(url, context);
31
+ }
32
+
33
+ return tsNodeLoad(url, context, defaultLoad);
34
+ }
@@ -20,11 +20,12 @@ async function generateBuilder(options, bundlerType) {
20
20
  return builder;
21
21
  }
22
22
  async function applyBuilderPlugins(builder, options) {
23
- const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR } = await import("../shared/builderPlugins/index.js");
23
+ const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderHookPlugin } = await import("../shared/builderPlugins/index.js");
24
24
  builder.addPlugins([
25
25
  builderPluginAdapterBasic(),
26
26
  builderPluginAdapterSSR(options),
27
- builderPluginAdapterHtml(options)
27
+ builderPluginAdapterHtml(options),
28
+ builderHookPlugin(options)
28
29
  ]);
29
30
  builder.addPlugins([
30
31
  builderPluginAdapterCopy(options)
@@ -0,0 +1,26 @@
1
+ const builderHookPlugin = (options) => ({
2
+ name: "builder-plugin-support-modern-hooks",
3
+ setup(api) {
4
+ var _internalContext_pluginAPI;
5
+ const _internalContext = options.appContext._internalContext;
6
+ const hooks = (_internalContext_pluginAPI = _internalContext.pluginAPI) === null || _internalContext_pluginAPI === void 0 ? void 0 : _internalContext_pluginAPI.getHooks();
7
+ api.modifyBundlerChain(async (chain, utils) => {
8
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyBundlerChain.call(chain, utils));
9
+ });
10
+ api.modifyRsbuildConfig(async (config, utils) => {
11
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyRsbuildConfig.call(config, utils));
12
+ });
13
+ api.modifyRspackConfig(async (config, utils) => {
14
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyRspackConfig.call(config, utils));
15
+ });
16
+ api.modifyWebpackChain(async (chain, utils) => {
17
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyWebpackChain.call(chain, utils));
18
+ });
19
+ api.modifyWebpackConfig(async (config, utils) => {
20
+ await (hooks === null || hooks === void 0 ? void 0 : hooks.modifyWebpackConfig.call(config, utils));
21
+ });
22
+ }
23
+ });
24
+ export {
25
+ builderHookPlugin
26
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./adapterBasic";
2
2
  export * from "./adapterHtml";
3
3
  export * from "./adapterSSR";
4
+ export * from "./builderHooks";
@@ -1,4 +1,5 @@
1
1
  import { pathToFileURL } from 'url';
2
+ import { load as esbuildLoad } from 'esbuild-register/loader';
2
3
  import { createMatchPath } from './utils.mjs';
3
4
 
4
5
  let matchPath;
@@ -17,4 +18,16 @@ export function resolve(specifier, context, defaultResolve) {
17
18
  : defaultResolve(specifier, context);
18
19
  }
19
20
 
20
- export { load } from 'esbuild-register/loader';
21
+ export function load(url, context, defaultLoad) {
22
+ const filePath = new URL(url).pathname;
23
+
24
+ if (url.startsWith('node:')) {
25
+ return defaultLoad(url, context);
26
+ }
27
+
28
+ if (filePath.includes('node_modules')) {
29
+ return defaultLoad(url, context);
30
+ }
31
+
32
+ return esbuildLoad(url, context, defaultLoad);
33
+ }
@@ -1,5 +1,6 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { resolve as tsNodeResolve } from 'ts-node/esm';
3
+ import { load as tsNodeLoad } from 'ts-node/esm';
3
4
  import { createMatchPath } from './utils.mjs';
4
5
 
5
6
  let matchPath;
@@ -18,4 +19,16 @@ export function resolve(specifier, context, defaultResolve) {
18
19
  : tsNodeResolve(specifier, context, defaultResolve);
19
20
  }
20
21
 
21
- export { transformSource, load } from 'ts-node/esm';
22
+ export function load(url, context, defaultLoad) {
23
+ const filePath = new URL(url).pathname;
24
+
25
+ if (url.startsWith('node:')) {
26
+ return defaultLoad(url, context);
27
+ }
28
+
29
+ if (filePath.includes('node_modules')) {
30
+ return defaultLoad(url, context);
31
+ }
32
+
33
+ return tsNodeLoad(url, context, defaultLoad);
34
+ }
@@ -0,0 +1,4 @@
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import type { Bundler } from '../../../types';
3
+ import type { BuilderOptions } from '../types';
4
+ export declare const builderHookPlugin: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,3 +1,4 @@
1
1
  export * from './adapterBasic';
2
2
  export * from './adapterHtml';
3
3
  export * from './adapterSSR';
4
+ export * from './builderHooks';
@@ -4,3 +4,4 @@ export function initialize({ appDir, alias, tsconfigPath }: {
4
4
  tsconfigPath: any;
5
5
  }): Promise<void>;
6
6
  export function resolve(specifier: any, context: any, defaultResolve: any): any;
7
+ export function load(url: any, context: any, defaultLoad: any): any;
@@ -4,3 +4,4 @@ export function initialize({ appDir, alias, tsconfigPath }: {
4
4
  tsconfigPath: any;
5
5
  }): Promise<void>;
6
6
  export function resolve(specifier: any, context: any, defaultResolve: any): any;
7
+ export function load(url: any, context: any, defaultLoad: any): any;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.64.2",
18
+ "version": "2.64.3-alpha.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -80,7 +80,7 @@
80
80
  "@babel/parser": "^7.22.15",
81
81
  "@babel/traverse": "^7.23.2",
82
82
  "@babel/types": "^7.26.0",
83
- "@rsbuild/core": "1.2.7",
83
+ "@rsbuild/core": "1.2.8",
84
84
  "@rsbuild/plugin-node-polyfill": "1.3.0",
85
85
  "@swc/helpers": "0.5.13",
86
86
  "es-module-lexer": "^1.1.0",
@@ -91,20 +91,20 @@
91
91
  "ndepe": "0.1.5",
92
92
  "pkg-types": "^1.1.0",
93
93
  "std-env": "^3.7.0",
94
- "@modern-js/core": "2.64.2",
95
- "@modern-js/node-bundle-require": "2.64.2",
96
- "@modern-js/plugin-data-loader": "2.64.2",
97
- "@modern-js/plugin": "2.64.2",
98
- "@modern-js/plugin-i18n": "2.64.2",
99
- "@modern-js/plugin-v2": "2.64.2",
100
- "@modern-js/rsbuild-plugin-esbuild": "2.64.2",
101
- "@modern-js/prod-server": "2.64.2",
102
- "@modern-js/server": "2.64.2",
103
- "@modern-js/server-core": "2.64.2",
104
- "@modern-js/server-utils": "2.64.2",
105
- "@modern-js/types": "2.64.2",
106
- "@modern-js/uni-builder": "2.64.2",
107
- "@modern-js/utils": "2.64.2"
94
+ "@modern-js/core": "2.64.3",
95
+ "@modern-js/plugin": "2.64.3",
96
+ "@modern-js/plugin-i18n": "2.64.3",
97
+ "@modern-js/plugin-v2": "2.64.3",
98
+ "@modern-js/prod-server": "2.64.3",
99
+ "@modern-js/server": "2.64.3",
100
+ "@modern-js/rsbuild-plugin-esbuild": "2.64.3",
101
+ "@modern-js/node-bundle-require": "2.64.3",
102
+ "@modern-js/server-core": "2.64.3",
103
+ "@modern-js/server-utils": "2.64.3",
104
+ "@modern-js/uni-builder": "2.64.3",
105
+ "@modern-js/types": "2.64.3",
106
+ "@modern-js/utils": "2.64.3",
107
+ "@modern-js/plugin-data-loader": "2.64.3"
108
108
  },
109
109
  "devDependencies": {
110
110
  "@rsbuild/plugin-webpack-swc": "1.0.9",
@@ -115,9 +115,9 @@
115
115
  "ts-node": "^10.9.1",
116
116
  "tsconfig-paths": "^4.2.0",
117
117
  "typescript": "^5",
118
- "webpack": "^5.97.1",
119
- "@scripts/build": "2.64.2",
120
- "@scripts/jest-config": "2.64.2"
118
+ "webpack": "^5.98.0",
119
+ "@scripts/build": "2.64.3",
120
+ "@scripts/jest-config": "2.64.3"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "ts-node": "^10.7.0",
@@ -134,8 +134,7 @@
134
134
  "sideEffects": false,
135
135
  "publishConfig": {
136
136
  "registry": "https://registry.npmjs.org/",
137
- "access": "public",
138
- "provenance": true
137
+ "access": "public"
139
138
  },
140
139
  "scripts": {
141
140
  "new": "modern-lib new",