@modern-js/module-tools 1.7.0 → 1.7.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 1.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b2f90f8: feat: add addRuntimeExports hooks for module-tools
8
+ feat: 为 module-tools 添加 addRuntimeExports 钩子
9
+
3
10
  ## 1.7.0
4
11
 
5
12
  ### Minor Changes
@@ -4,6 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
+ import { createAsyncWaterfall } from '@modern-js/plugin';
7
8
  import { buildHooks, lifecycle as buildLifeCycle } from "./build";
8
9
  import { devHooks, lifecycle as devLifeCycle } from "./dev";
9
10
  export { buildLifeCycle, devLifeCycle };
@@ -11,4 +12,7 @@ export const lifecycle = () => {
11
12
  devLifeCycle();
12
13
  buildLifeCycle();
13
14
  };
14
- export const hooks = _objectSpread(_objectSpread({}, buildHooks), devHooks);
15
+ export const addRuntimeExports = createAsyncWaterfall();
16
+ export const hooks = _objectSpread(_objectSpread(_objectSpread({}, buildHooks), devHooks), {}, {
17
+ addRuntimeExports
18
+ });
@@ -1,4 +1,4 @@
1
- import { Import } from '@modern-js/utils';
1
+ import { Import, fs } from '@modern-js/utils';
2
2
  import ChangesetPlugin from '@modern-js/plugin-changeset';
3
3
  import LintPlugin from '@modern-js/plugin-jarvis';
4
4
  import { hooks } from "./hooks";
@@ -20,6 +20,19 @@ export default (() => ({
20
20
  locale
21
21
  });
22
22
  return {
23
+ // copy from @modern-js/plugin-analyze/src/index.ts
24
+ async prepare() {
25
+ const appContext = api.useAppContext();
26
+ const hookRunners = api.useHookRunners();
27
+
28
+ try {
29
+ fs.emptydirSync(appContext.internalDirectory);
30
+ } catch (_unused) {// FIXME:
31
+ }
32
+
33
+ await hookRunners.addRuntimeExports();
34
+ },
35
+
23
36
  validateSchema() {
24
37
  return schema.addSchema();
25
38
  },
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.addRuntimeExports = void 0;
6
7
  Object.defineProperty(exports, "buildLifeCycle", {
7
8
  enumerable: true,
8
9
  get: function () {
@@ -17,6 +18,8 @@ Object.defineProperty(exports, "devLifeCycle", {
17
18
  });
18
19
  exports.lifecycle = exports.hooks = void 0;
19
20
 
21
+ var _plugin = require("@modern-js/plugin");
22
+
20
23
  var _build = require("./build");
21
24
 
22
25
  var _dev = require("./dev");
@@ -33,7 +36,11 @@ const lifecycle = () => {
33
36
  };
34
37
 
35
38
  exports.lifecycle = lifecycle;
39
+ const addRuntimeExports = (0, _plugin.createAsyncWaterfall)();
40
+ exports.addRuntimeExports = addRuntimeExports;
36
41
 
37
- const hooks = _objectSpread(_objectSpread({}, _build.buildHooks), _dev.devHooks);
42
+ const hooks = _objectSpread(_objectSpread(_objectSpread({}, _build.buildHooks), _dev.devHooks), {}, {
43
+ addRuntimeExports
44
+ });
38
45
 
39
46
  exports.hooks = hooks;
@@ -61,6 +61,19 @@ var _default = () => ({
61
61
  locale
62
62
  });
63
63
  return {
64
+ // copy from @modern-js/plugin-analyze/src/index.ts
65
+ async prepare() {
66
+ const appContext = api.useAppContext();
67
+ const hookRunners = api.useHookRunners();
68
+
69
+ try {
70
+ _utils.fs.emptydirSync(appContext.internalDirectory);
71
+ } catch (_unused) {// FIXME:
72
+ }
73
+
74
+ await hookRunners.addRuntimeExports();
75
+ },
76
+
64
77
  validateSchema() {
65
78
  return schema.addSchema();
66
79
  },
@@ -2,7 +2,9 @@ import { lifecycle as buildLifeCycle } from './build';
2
2
  import { lifecycle as devLifeCycle } from './dev';
3
3
  export { buildLifeCycle, devLifeCycle };
4
4
  export declare const lifecycle: () => void;
5
+ export declare const addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
5
6
  export declare const hooks: {
7
+ addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
6
8
  moduleToolsMenu: import("@modern-js/plugin").ParallelWorkflow<undefined, {
7
9
  name: string;
8
10
  value: string;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.7.0",
14
+ "version": "1.7.1",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js"
17
17
  },