@modern-js/runtime 1.2.1 → 1.2.4

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,64 @@
1
1
  # @modern-js/runtime
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 94d02b35: feat(plugin-runtime): convert to new plugin
8
+ - 808cec13: fix(plugin-runtime): fix usePlugins error
9
+ - 681a1ff9: feat: remove unnecessary peerDependencies
10
+ - Updated dependencies [c2046f37]
11
+ - Updated dependencies [a2261fed]
12
+ - Updated dependencies [cee0efcc]
13
+ - Updated dependencies [94d02b35]
14
+ - Updated dependencies [57e8ce98]
15
+ - Updated dependencies [e31ce644]
16
+ - Updated dependencies [681a1ff9]
17
+ - Updated dependencies [e8bbc315]
18
+ - @modern-js/utils@1.3.6
19
+ - @modern-js/runtime-core@1.4.0
20
+ - @modern-js/plugin-router@1.2.6
21
+ - @modern-js/plugin-state@1.2.2
22
+ - @modern-js/plugin-ssr@1.2.4
23
+
24
+ ## 1.2.3
25
+
26
+ ### Patch Changes
27
+
28
+ - 6891e4c2: add theme token some config logic
29
+ - 0cd8b592: fix: runtime head and loadable type not found
30
+ - Updated dependencies [b376c8d6]
31
+ - Updated dependencies [735b2a81]
32
+ - Updated dependencies [e62c4efd]
33
+ - Updated dependencies [5ed05e65]
34
+ - Updated dependencies [735b2a81]
35
+ - Updated dependencies [e2a8233f]
36
+ - @modern-js/core@1.4.2
37
+ - @modern-js/plugin-ssr@1.2.2
38
+ - @modern-js/runtime-core@1.2.3
39
+
40
+ ## 1.2.2
41
+
42
+ ### Patch Changes
43
+
44
+ - d099e5c5: fix error when modify modern.config.js
45
+ - 24f616ca: feat: support custom meta info
46
+ - Updated dependencies [816fd721]
47
+ - Updated dependencies [d9cc5ea9]
48
+ - Updated dependencies [bfbea9a7]
49
+ - Updated dependencies [bd819a8d]
50
+ - Updated dependencies [ec4dbffb]
51
+ - Updated dependencies [d099e5c5]
52
+ - Updated dependencies [bada2879]
53
+ - Updated dependencies [24f616ca]
54
+ - Updated dependencies [bd819a8d]
55
+ - Updated dependencies [272cab15]
56
+ - @modern-js/plugin-ssr@1.2.1
57
+ - @modern-js/core@1.4.0
58
+ - @modern-js/plugin-router@1.2.2
59
+ - @modern-js/runtime-core@1.2.2
60
+ - @modern-js/utils@1.3.0
61
+
3
62
  ## 1.2.1
4
63
 
5
64
  ### Patch Changes
@@ -1,46 +1,42 @@
1
1
  import path from 'path';
2
- import { PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
3
- import { createPlugin, usePlugins, useAppContext } from '@modern-js/core';
4
-
5
- const useInternalDirectory = () => {
6
- try {
7
- return useAppContext().internalDirectory;
8
- } catch (_unused) {
9
- return path.join(process.cwd(), 'node_modules/.modern-js');
10
- }
11
- }; // eslint-disable-next-line react-hooks/rules-of-hooks
12
-
13
-
14
- usePlugins([require.resolve('@modern-js/plugin-state/cli'), require.resolve('@modern-js/plugin-router/cli'), require.resolve('@modern-js/plugin-ssr/cli')]);
15
- export default createPlugin(() => {
16
- let runtimeExportsUtils = {};
17
- return {
18
- config() {
19
- // eslint-disable-next-line react-hooks/rules-of-hooks
20
- const dir = useInternalDirectory();
21
- runtimeExportsUtils = createRuntimeExportsUtils(dir, 'index');
22
- return {
23
- runtime: {},
24
- runtimeByEntries: {},
25
- source: {
26
- alias: {
27
- '@modern-js/runtime$': runtimeExportsUtils.getPath()
2
+ import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, cleanRequireCache } from '@modern-js/utils';
3
+ import PluginState from '@modern-js/plugin-state/cli';
4
+ import PluginRouter from '@modern-js/plugin-router/cli';
5
+ import PluginSSR from '@modern-js/plugin-ssr/cli';
6
+ export default (() => ({
7
+ name: '@modern-js/runtime',
8
+ post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-design-token'],
9
+ usePlugins: [PluginState(), PluginRouter(), PluginSSR()],
10
+ setup: api => {
11
+ let runtimeExportsUtils = {};
12
+ return {
13
+ config() {
14
+ const dir = api.useAppContext().internalDirectory;
15
+ runtimeExportsUtils = createRuntimeExportsUtils(dir, 'index');
16
+ return {
17
+ runtime: {},
18
+ runtimeByEntries: {},
19
+ source: {
20
+ alias: {
21
+ '@modern-js/runtime$': runtimeExportsUtils.getPath()
22
+ }
28
23
  }
29
- }
30
- };
31
- },
24
+ };
25
+ },
32
26
 
33
- validateSchema() {
34
- return PLUGIN_SCHEMAS['@modern-js/runtime'];
35
- },
27
+ validateSchema() {
28
+ return PLUGIN_SCHEMAS['@modern-js/runtime'];
29
+ },
36
30
 
37
- addRuntimeExports() {
38
- const runtimePackage = path.resolve(__dirname, '../../../../');
39
- runtimeExportsUtils.addExport(`export * from '${runtimePackage}'`);
40
- }
31
+ addRuntimeExports() {
32
+ const runtimePackage = path.resolve(__dirname, '../../../../');
33
+ runtimeExportsUtils.addExport(`export * from '${runtimePackage}'`);
34
+ },
41
35
 
42
- };
43
- }, {
44
- name: '@modern-js/runtime',
45
- post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state']
46
- });
36
+ async beforeRestart() {
37
+ cleanRequireCache([require.resolve('@modern-js/plugin-state/cli'), require.resolve('@modern-js/plugin-router/cli'), require.resolve('@modern-js/plugin-ssr/cli')]);
38
+ }
39
+
40
+ };
41
+ }
42
+ }));
@@ -9,53 +9,51 @@ var _path = _interopRequireDefault(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _core = require("@modern-js/core");
12
+ var _cli = _interopRequireDefault(require("@modern-js/plugin-state/cli"));
13
+
14
+ var _cli2 = _interopRequireDefault(require("@modern-js/plugin-router/cli"));
15
+
16
+ var _cli3 = _interopRequireDefault(require("@modern-js/plugin-ssr/cli"));
13
17
 
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
16
- const useInternalDirectory = () => {
17
- try {
18
- return (0, _core.useAppContext)().internalDirectory;
19
- } catch (_unused) {
20
- return _path.default.join(process.cwd(), 'node_modules/.modern-js');
21
- }
22
- }; // eslint-disable-next-line react-hooks/rules-of-hooks
23
-
24
-
25
- (0, _core.usePlugins)([require.resolve('@modern-js/plugin-state/cli'), require.resolve('@modern-js/plugin-router/cli'), require.resolve('@modern-js/plugin-ssr/cli')]);
26
-
27
- var _default = (0, _core.createPlugin)(() => {
28
- let runtimeExportsUtils = {};
29
- return {
30
- config() {
31
- // eslint-disable-next-line react-hooks/rules-of-hooks
32
- const dir = useInternalDirectory();
33
- runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(dir, 'index');
34
- return {
35
- runtime: {},
36
- runtimeByEntries: {},
37
- source: {
38
- alias: {
39
- '@modern-js/runtime$': runtimeExportsUtils.getPath()
20
+ var _default = () => ({
21
+ name: '@modern-js/runtime',
22
+ post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-design-token'],
23
+ usePlugins: [(0, _cli.default)(), (0, _cli2.default)(), (0, _cli3.default)()],
24
+ setup: api => {
25
+ let runtimeExportsUtils = {};
26
+ return {
27
+ config() {
28
+ const dir = api.useAppContext().internalDirectory;
29
+ runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(dir, 'index');
30
+ return {
31
+ runtime: {},
32
+ runtimeByEntries: {},
33
+ source: {
34
+ alias: {
35
+ '@modern-js/runtime$': runtimeExportsUtils.getPath()
36
+ }
40
37
  }
41
- }
42
- };
43
- },
38
+ };
39
+ },
44
40
 
45
- validateSchema() {
46
- return _utils.PLUGIN_SCHEMAS['@modern-js/runtime'];
47
- },
41
+ validateSchema() {
42
+ return _utils.PLUGIN_SCHEMAS['@modern-js/runtime'];
43
+ },
48
44
 
49
- addRuntimeExports() {
50
- const runtimePackage = _path.default.resolve(__dirname, '../../../../');
45
+ addRuntimeExports() {
46
+ const runtimePackage = _path.default.resolve(__dirname, '../../../../');
51
47
 
52
- runtimeExportsUtils.addExport(`export * from '${runtimePackage}'`);
53
- }
48
+ runtimeExportsUtils.addExport(`export * from '${runtimePackage}'`);
49
+ },
54
50
 
55
- };
56
- }, {
57
- name: '@modern-js/runtime',
58
- post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state']
51
+ async beforeRestart() {
52
+ (0, _utils.cleanRequireCache)([require.resolve('@modern-js/plugin-state/cli'), require.resolve('@modern-js/plugin-router/cli'), require.resolve('@modern-js/plugin-ssr/cli')]);
53
+ }
54
+
55
+ };
56
+ }
59
57
  });
60
58
 
61
59
  exports.default = _default;
@@ -1,43 +1,59 @@
1
- import path from 'path';
2
- import { PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
3
- import { createPlugin, usePlugins, useAppContext } from '@modern-js/core';
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
2
 
5
- var useInternalDirectory = function useInternalDirectory() {
6
- try {
7
- return useAppContext().internalDirectory;
8
- } catch (_unused) {
9
- return path.join(process.cwd(), 'node_modules/.modern-js');
10
- }
11
- }; // eslint-disable-next-line react-hooks/rules-of-hooks
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
4
 
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
6
 
14
- usePlugins([require.resolve('@modern-js/plugin-state/cli'), require.resolve('@modern-js/plugin-router/cli'), require.resolve('@modern-js/plugin-ssr/cli')]);
15
- export default createPlugin(function () {
16
- var runtimeExportsUtils = {};
7
+ import path from 'path';
8
+ import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, cleanRequireCache } from '@modern-js/utils';
9
+ import PluginState from '@modern-js/plugin-state/cli';
10
+ import PluginRouter from '@modern-js/plugin-router/cli';
11
+ import PluginSSR from '@modern-js/plugin-ssr/cli';
12
+ export default (function () {
17
13
  return {
18
- config: function config() {
19
- // eslint-disable-next-line react-hooks/rules-of-hooks
20
- var dir = useInternalDirectory();
21
- runtimeExportsUtils = createRuntimeExportsUtils(dir, 'index');
14
+ name: '@modern-js/runtime',
15
+ post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-design-token'],
16
+ usePlugins: [PluginState(), PluginRouter(), PluginSSR()],
17
+ setup: function setup(api) {
18
+ var runtimeExportsUtils = {};
22
19
  return {
23
- runtime: {},
24
- runtimeByEntries: {},
25
- source: {
26
- alias: {
27
- '@modern-js/runtime$': runtimeExportsUtils.getPath()
28
- }
20
+ config: function config() {
21
+ var dir = api.useAppContext().internalDirectory;
22
+ runtimeExportsUtils = createRuntimeExportsUtils(dir, 'index');
23
+ return {
24
+ runtime: {},
25
+ runtimeByEntries: {},
26
+ source: {
27
+ alias: {
28
+ '@modern-js/runtime$': runtimeExportsUtils.getPath()
29
+ }
30
+ }
31
+ };
32
+ },
33
+ validateSchema: function validateSchema() {
34
+ return PLUGIN_SCHEMAS['@modern-js/runtime'];
35
+ },
36
+ addRuntimeExports: function addRuntimeExports() {
37
+ var runtimePackage = path.resolve(__dirname, '../../../../');
38
+ runtimeExportsUtils.addExport("export * from '".concat(runtimePackage, "'"));
39
+ },
40
+ beforeRestart: function beforeRestart() {
41
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
42
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
43
+ while (1) {
44
+ switch (_context.prev = _context.next) {
45
+ case 0:
46
+ cleanRequireCache([require.resolve('@modern-js/plugin-state/cli'), require.resolve('@modern-js/plugin-router/cli'), require.resolve('@modern-js/plugin-ssr/cli')]);
47
+
48
+ case 1:
49
+ case "end":
50
+ return _context.stop();
51
+ }
52
+ }
53
+ }, _callee);
54
+ }))();
29
55
  }
30
56
  };
31
- },
32
- validateSchema: function validateSchema() {
33
- return PLUGIN_SCHEMAS['@modern-js/runtime'];
34
- },
35
- addRuntimeExports: function addRuntimeExports() {
36
- var runtimePackage = path.resolve(__dirname, '../../../../');
37
- runtimeExportsUtils.addExport("export * from '".concat(runtimePackage, "'"));
38
57
  }
39
58
  };
40
- }, {
41
- name: '@modern-js/runtime',
42
- post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state']
43
59
  });
@@ -1,3 +1,5 @@
1
- declare const _default: any;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+
3
+ declare const _default: () => CliPlugin;
2
4
 
3
5
  export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.1",
14
+ "version": "1.2.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./type.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -103,22 +103,22 @@
103
103
  },
104
104
  "dependencies": {
105
105
  "@babel/runtime": "^7",
106
- "@modern-js/plugin-router": "^1.2.1",
107
- "@modern-js/plugin-ssr": "^1.2.0",
108
- "@modern-js/plugin-state": "^1.2.1",
109
- "@modern-js/runtime-core": "^1.2.1",
110
- "@modern-js/utils": "^1.2.2",
106
+ "@modern-js/plugin-router": "^1.2.6",
107
+ "@modern-js/plugin-ssr": "^1.2.4",
108
+ "@modern-js/plugin-state": "^1.2.2",
109
+ "@modern-js/runtime-core": "^1.4.0",
110
+ "@modern-js/utils": "^1.3.6",
111
111
  "@modern-js/bff-runtime": "^1.2.1",
112
112
  "@modern-js/create-request": "^1.2.1",
113
113
  "@loadable/component": "^5.15.0",
114
+ "@types/loadable__component": "^5.13.4",
115
+ "@types/react-helmet": "^6.1.2",
114
116
  "react-helmet": "^6.1.0",
115
117
  "styled-components": "^5.3.1"
116
118
  },
117
119
  "devDependencies": {
118
- "@modern-js/core": "^1.3.2",
120
+ "@modern-js/core": "^1.6.0",
119
121
  "@scripts/build": "0.0.0",
120
- "@types/loadable__component": "^5.13.4",
121
- "@types/react-helmet": "^6.1.2",
122
122
  "@types/styled-components": "^5.1.13",
123
123
  "@types/jest": "^26",
124
124
  "@types/node": "^14",
@@ -128,15 +128,11 @@
128
128
  "jest": "^27",
129
129
  "@scripts/jest-config": "0.0.0"
130
130
  },
131
- "peerDependencies": {
132
- "@modern-js/core": "^1.3.2"
133
- },
134
131
  "sideEffects": false,
135
132
  "modernConfig": {},
136
133
  "publishConfig": {
137
134
  "registry": "https://registry.npmjs.org/",
138
- "access": "public",
139
- "types": "./type.d.ts"
135
+ "access": "public"
140
136
  },
141
137
  "scripts": {
142
138
  "new": "modern new",
@@ -1,11 +1,9 @@
1
- import { createApp, createPlugin, useRuntimeContext } from '../src';
1
+ import { createApp } from '../src';
2
2
  import plugin from '../src/cli';
3
3
 
4
4
  describe('plugin-runtime', () => {
5
5
  it('default', () => {
6
6
  expect(plugin).toBeDefined();
7
7
  expect(createApp).toBeDefined();
8
- expect(createPlugin).toBeDefined();
9
- expect(useRuntimeContext).toBeDefined();
10
8
  });
11
9
  });