@modern-js/runtime 2.3.0 → 2.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @modern-js/runtime
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 9e907ec: chore: catch react-dom/server require for react 17
8
+ chore: 捕获引入 react-dom/server 的逻辑,避免在 react 17 下报错
9
+ - Updated dependencies [98a2733]
10
+ - Updated dependencies [8c2db5f]
11
+ - @modern-js/utils@2.4.0
12
+ - @modern-js/plugin@2.4.0
13
+ - @modern-js/types@2.4.0
14
+
3
15
  ## 2.3.0
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,30 +1,26 @@
1
-
2
1
  <p align="center">
3
2
  <a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
4
3
  </p>
4
+
5
+ <h1 align="center">Modern.js</h1>
6
+
5
7
  <p align="center">
6
- 现代 Web 工程体系
7
- <br/>
8
- <a href="https://modernjs.dev" target="blank">
9
- modernjs.dev
10
- </a>
11
- </p>
12
- <p align="center">
13
- The meta-framework suite designed from scratch for frontend-focused modern web development
8
+ A Progressive React Framework for modern web development.
14
9
  </p>
15
10
 
16
- # Introduction
17
-
18
- > The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.
11
+ ## Getting Started
19
12
 
20
- - [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)
13
+ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.
21
14
 
22
- ## Getting Started
15
+ ## Documentation
23
16
 
24
- - [Quick Start](https://modernjs.dev/docs/start)
25
- - [Guides](https://modernjs.dev/docs/guides)
26
- - [API References](https://modernjs.dev/docs/apis)
17
+ - [English Documentation](https://modernjs.dev/en/)
18
+ - [中文文档](https://modernjs.dev)
27
19
 
28
20
  ## Contributing
29
21
 
30
- - [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)
22
+ Please read the [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md).
23
+
24
+ ## License
25
+
26
+ Modern.js is [MIT licensed](https://github.com/modern-js-dev/modern.js/blob/main/LICENSE).
@@ -4,10 +4,10 @@ import {
4
4
  DOCUMENT_CHUNKSMAP_PLACEHOLDER,
5
5
  DOCUMENT_SSRDATASCRIPT_PLACEHOLDER
6
6
  } from "./constants";
7
- import { DocumentStructrueContext } from "./DocumentStructrueContext";
7
+ import { DocumentStructureContext } from "./DocumentStructureContext";
8
8
  import { DefaultRoot } from "./Root";
9
9
  function Body(props) {
10
- const { hasSetRoot } = useContext(DocumentStructrueContext);
10
+ const { hasSetRoot } = useContext(DocumentStructureContext);
11
11
  const { children } = props;
12
12
  return /* @__PURE__ */ jsxs("body", {
13
13
  children: [
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- const DocumentStructrueContext = React.createContext({
2
+ const DocumentStructureContext = React.createContext({
3
3
  hasSetHead: false,
4
4
  hasSetScripts: false,
5
5
  hasSetBody: false,
@@ -7,5 +7,5 @@ const DocumentStructrueContext = React.createContext({
7
7
  hasSetLinks: false
8
8
  });
9
9
  export {
10
- DocumentStructrueContext
10
+ DocumentStructureContext
11
11
  };
@@ -1,11 +1,11 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
- import { DocumentStructrueContext } from "./DocumentStructrueContext";
3
+ import { DocumentStructureContext } from "./DocumentStructureContext";
4
4
  import { Scripts } from "./Scripts";
5
5
  import { Links } from "./Links";
6
6
  import { DOCUMENT_META_PLACEHOLDER } from "./constants";
7
7
  function Head(props) {
8
- const { hasSetScripts, hasSetLinks } = useContext(DocumentStructrueContext);
8
+ const { hasSetScripts, hasSetLinks } = useContext(DocumentStructureContext);
9
9
  const { children } = props;
10
10
  return /* @__PURE__ */ jsxs("head", {
11
11
  children: [
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Body } from "./Body";
3
- import { DocumentStructrueContext } from "./DocumentStructrueContext";
3
+ import { DocumentStructureContext } from "./DocumentStructureContext";
4
4
  import { Head } from "./Head";
5
5
  function findTargetChild(tag, children) {
6
6
  return children.find((item) => getEleType(item) === tag);
@@ -56,7 +56,7 @@ function Html(props) {
56
56
  });
57
57
  }
58
58
  return /* @__PURE__ */ jsx("html", {
59
- children: /* @__PURE__ */ jsxs(DocumentStructrueContext.Provider, {
59
+ children: /* @__PURE__ */ jsxs(DocumentStructureContext.Provider, {
60
60
  value: {
61
61
  hasSetHead,
62
62
  hasSetScripts,
@@ -1,6 +1,6 @@
1
1
  export * from "./Html";
2
2
  export * from "./DocumentContext";
3
- export * from "./DocumentStructrueContext";
3
+ export * from "./DocumentStructureContext";
4
4
  export * from "./Head";
5
5
  export * from "./Body";
6
6
  export * from "./Root";
@@ -18,9 +18,6 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { Transform } from "stream";
21
- import {
22
- renderToPipeableStream
23
- } from "react-dom/server";
24
21
  import { RenderLevel } from "../types";
25
22
  import { getTemplates } from "./template";
26
23
  function renderToPipe(rootElement, context, options) {
@@ -28,6 +25,11 @@ function renderToPipe(rootElement, context, options) {
28
25
  const { ssrContext } = context;
29
26
  const forUserPipe = (stream) => {
30
27
  return new Promise((resolve) => {
28
+ let renderToPipeableStream;
29
+ try {
30
+ ({ renderToPipeableStream } = require("react-dom/server"));
31
+ } catch (e) {
32
+ }
31
33
  const { pipe } = renderToPipeableStream(rootElement, __spreadProps(__spreadValues({}, options), {
32
34
  onShellReady() {
33
35
  var _a;
@@ -23,10 +23,10 @@ module.exports = __toCommonJS(Body_exports);
23
23
  var import_jsx_runtime = require("react/jsx-runtime");
24
24
  var import_react = require("react");
25
25
  var import_constants = require("./constants");
26
- var import_DocumentStructrueContext = require("./DocumentStructrueContext");
26
+ var import_DocumentStructureContext = require("./DocumentStructureContext");
27
27
  var import_Root = require("./Root");
28
28
  function Body(props) {
29
- const { hasSetRoot } = (0, import_react.useContext)(import_DocumentStructrueContext.DocumentStructrueContext);
29
+ const { hasSetRoot } = (0, import_react.useContext)(import_DocumentStructureContext.DocumentStructureContext);
30
30
  const { children } = props;
31
31
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("body", {
32
32
  children: [
@@ -21,13 +21,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  mod
22
22
  ));
23
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var DocumentStructrueContext_exports = {};
25
- __export(DocumentStructrueContext_exports, {
26
- DocumentStructrueContext: () => DocumentStructrueContext
24
+ var DocumentStructureContext_exports = {};
25
+ __export(DocumentStructureContext_exports, {
26
+ DocumentStructureContext: () => DocumentStructureContext
27
27
  });
28
- module.exports = __toCommonJS(DocumentStructrueContext_exports);
28
+ module.exports = __toCommonJS(DocumentStructureContext_exports);
29
29
  var import_react = __toESM(require("react"));
30
- const DocumentStructrueContext = import_react.default.createContext({
30
+ const DocumentStructureContext = import_react.default.createContext({
31
31
  hasSetHead: false,
32
32
  hasSetScripts: false,
33
33
  hasSetBody: false,
@@ -36,5 +36,5 @@ const DocumentStructrueContext = import_react.default.createContext({
36
36
  });
37
37
  // Annotate the CommonJS export names for ESM import in node:
38
38
  0 && (module.exports = {
39
- DocumentStructrueContext
39
+ DocumentStructureContext
40
40
  });
@@ -23,12 +23,12 @@ __export(Head_exports, {
23
23
  module.exports = __toCommonJS(Head_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_react = require("react");
26
- var import_DocumentStructrueContext = require("./DocumentStructrueContext");
26
+ var import_DocumentStructureContext = require("./DocumentStructureContext");
27
27
  var import_Scripts = require("./Scripts");
28
28
  var import_Links = require("./Links");
29
29
  var import_constants = require("./constants");
30
30
  function Head(props) {
31
- const { hasSetScripts, hasSetLinks } = (0, import_react.useContext)(import_DocumentStructrueContext.DocumentStructrueContext);
31
+ const { hasSetScripts, hasSetLinks } = (0, import_react.useContext)(import_DocumentStructureContext.DocumentStructureContext);
32
32
  const { children } = props;
33
33
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("head", {
34
34
  children: [
@@ -22,7 +22,7 @@ __export(Html_exports, {
22
22
  module.exports = __toCommonJS(Html_exports);
23
23
  var import_jsx_runtime = require("react/jsx-runtime");
24
24
  var import_Body = require("./Body");
25
- var import_DocumentStructrueContext = require("./DocumentStructrueContext");
25
+ var import_DocumentStructureContext = require("./DocumentStructureContext");
26
26
  var import_Head = require("./Head");
27
27
  function findTargetChild(tag, children) {
28
28
  return children.find((item) => getEleType(item) === tag);
@@ -78,7 +78,7 @@ function Html(props) {
78
78
  });
79
79
  }
80
80
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("html", {
81
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_DocumentStructrueContext.DocumentStructrueContext.Provider, {
81
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_DocumentStructureContext.DocumentStructureContext.Provider, {
82
82
  value: {
83
83
  hasSetHead,
84
84
  hasSetScripts,
@@ -16,7 +16,7 @@ var document_exports = {};
16
16
  module.exports = __toCommonJS(document_exports);
17
17
  __reExport(document_exports, require("./Html"), module.exports);
18
18
  __reExport(document_exports, require("./DocumentContext"), module.exports);
19
- __reExport(document_exports, require("./DocumentStructrueContext"), module.exports);
19
+ __reExport(document_exports, require("./DocumentStructureContext"), module.exports);
20
20
  __reExport(document_exports, require("./Head"), module.exports);
21
21
  __reExport(document_exports, require("./Body"), module.exports);
22
22
  __reExport(document_exports, require("./Root"), module.exports);
@@ -38,7 +38,6 @@ __export(renderToPipe_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(renderToPipe_exports);
40
40
  var import_stream = require("stream");
41
- var import_server = require("react-dom/server");
42
41
  var import_types = require("../types");
43
42
  var import_template = require("./template");
44
43
  function renderToPipe(rootElement, context, options) {
@@ -46,7 +45,12 @@ function renderToPipe(rootElement, context, options) {
46
45
  const { ssrContext } = context;
47
46
  const forUserPipe = (stream) => {
48
47
  return new Promise((resolve) => {
49
- const { pipe } = (0, import_server.renderToPipeableStream)(rootElement, __spreadProps(__spreadValues({}, options), {
48
+ let renderToPipeableStream;
49
+ try {
50
+ ({ renderToPipeableStream } = require("react-dom/server"));
51
+ } catch (e) {
52
+ }
53
+ const { pipe } = renderToPipeableStream(rootElement, __spreadProps(__spreadValues({}, options), {
50
54
  onShellReady() {
51
55
  var _a;
52
56
  const { shellAfter, shellBefore } = (0, import_template.getTemplates)(
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER } from "./constants";
4
- import { DocumentStructrueContext } from "./DocumentStructrueContext";
4
+ import { DocumentStructureContext } from "./DocumentStructureContext";
5
5
  import { DefaultRoot } from "./Root";
6
6
  function Body(props) {
7
- var hasSetRoot = useContext(DocumentStructrueContext).hasSetRoot;
7
+ var hasSetRoot = useContext(DocumentStructureContext).hasSetRoot;
8
8
  var children = props.children;
9
9
  return /* @__PURE__ */ jsxs("body", {
10
10
  children: [
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- var DocumentStructrueContext = React.createContext({
2
+ var DocumentStructureContext = React.createContext({
3
3
  hasSetHead: false,
4
4
  hasSetScripts: false,
5
5
  hasSetBody: false,
6
6
  hasSetRoot: false,
7
7
  hasSetLinks: false
8
8
  });
9
- export { DocumentStructrueContext };
9
+ export { DocumentStructureContext };
@@ -1,11 +1,11 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
- import { DocumentStructrueContext } from "./DocumentStructrueContext";
3
+ import { DocumentStructureContext } from "./DocumentStructureContext";
4
4
  import { Scripts } from "./Scripts";
5
5
  import { Links } from "./Links";
6
6
  import { DOCUMENT_META_PLACEHOLDER } from "./constants";
7
7
  function Head(props) {
8
- var ref = useContext(DocumentStructrueContext), hasSetScripts = ref.hasSetScripts, hasSetLinks = ref.hasSetLinks;
8
+ var ref = useContext(DocumentStructureContext), hasSetScripts = ref.hasSetScripts, hasSetLinks = ref.hasSetLinks;
9
9
  var children = props.children;
10
10
  return /* @__PURE__ */ jsxs("head", {
11
11
  children: [
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Body } from "./Body";
3
- import { DocumentStructrueContext } from "./DocumentStructrueContext";
3
+ import { DocumentStructureContext } from "./DocumentStructureContext";
4
4
  import { Head } from "./Head";
5
5
  function findTargetChild(tag, children) {
6
6
  return children.find(function(item) {
@@ -79,7 +79,7 @@ function Html(props) {
79
79
  });
80
80
  }
81
81
  return /* @__PURE__ */ jsx("html", {
82
- children: /* @__PURE__ */ jsxs(DocumentStructrueContext.Provider, {
82
+ children: /* @__PURE__ */ jsxs(DocumentStructureContext.Provider, {
83
83
  value: {
84
84
  hasSetHead: hasSetHead,
85
85
  hasSetScripts: hasSetScripts,
@@ -1,6 +1,6 @@
1
1
  export * from "./Html";
2
2
  export * from "./DocumentContext";
3
- export * from "./DocumentStructrueContext";
3
+ export * from "./DocumentStructureContext";
4
4
  export * from "./Head";
5
5
  export * from "./Body";
6
6
  export * from "./Root";
@@ -58,7 +58,6 @@ function _objectSpreadProps(target, source) {
58
58
  return target;
59
59
  }
60
60
  import { Transform } from "stream";
61
- import { renderToPipeableStream } from "react-dom/server";
62
61
  import { RenderLevel } from "../types";
63
62
  import { getTemplates } from "./template";
64
63
  function renderToPipe(rootElement, context, options) {
@@ -70,6 +69,10 @@ function renderToPipe(rootElement, context, options) {
70
69
  var ssrContext = context.ssrContext;
71
70
  var forUserPipe = function(stream) {
72
71
  return new Promise(function(resolve) {
72
+ var renderToPipeableStream;
73
+ try {
74
+ renderToPipeableStream = require("react-dom/server").renderToPipeableStream;
75
+ } catch (e) {}
73
76
  var pipe = renderToPipeableStream(rootElement, _objectSpreadProps(_objectSpread({}, options), {
74
77
  onShellReady: function onShellReady() {
75
78
  var ref;
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- type DocumentStructrueContextProps = {
2
+ type DocumentStructureContextProps = {
3
3
  hasSetHead?: boolean;
4
4
  hasSetScripts?: boolean;
5
5
  hasSetLinks?: boolean;
@@ -7,5 +7,5 @@ type DocumentStructrueContextProps = {
7
7
  hasSetRoot?: boolean;
8
8
  docChild?: ReactNode;
9
9
  };
10
- export declare const DocumentStructrueContext: React.Context<DocumentStructrueContextProps>;
10
+ export declare const DocumentStructureContext: React.Context<DocumentStructureContextProps>;
11
11
  export {};
@@ -1,6 +1,6 @@
1
1
  export * from './Html';
2
2
  export * from './DocumentContext';
3
- export * from './DocumentStructrueContext';
3
+ export * from './DocumentStructureContext';
4
4
  export * from './Head';
5
5
  export * from './Body';
6
6
  export * from './Root';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="react" />
3
3
  import { Writable } from 'stream';
4
- import { RenderToPipeableStreamOptions } from 'react-dom/server';
4
+ import type { RenderToPipeableStreamOptions } from 'react-dom/server';
5
5
  import { RuntimeContext } from '../types';
6
6
  export type Pipe<T extends Writable> = (output: T) => Promise<T | string>;
7
7
  declare function renderToPipe(rootElement: React.ReactElement, context: RuntimeContext, options?: RenderToPipeableStreamOptions): Pipe<Writable>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/runtime",
3
- "description": "The meta-framework suite designed from scratch for frontend-focused modern web development.",
3
+ "description": "A Progressive React Framework for modern web development.",
4
4
  "homepage": "https://modernjs.dev",
5
5
  "bugs": "https://github.com/modern-js-dev/modern.js/issues",
6
6
  "repository": "modern-js-dev/modern.js",
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.3.0",
14
+ "version": "2.4.0",
15
15
  "engines": {
16
16
  "node": ">=14.17.6"
17
17
  },
@@ -147,9 +147,9 @@
147
147
  "serialize-javascript": "^6.0.0",
148
148
  "styled-components": "^5.3.1",
149
149
  "esbuild": "0.15.7",
150
- "@modern-js/plugin": "2.3.0",
151
- "@modern-js/types": "2.3.0",
152
- "@modern-js/utils": "2.3.0"
150
+ "@modern-js/plugin": "2.4.0",
151
+ "@modern-js/types": "2.4.0",
152
+ "@modern-js/utils": "2.4.0"
153
153
  },
154
154
  "peerDependencies": {
155
155
  "react": ">=17",
@@ -170,11 +170,11 @@
170
170
  "react-dom": "^18",
171
171
  "ts-jest": "^27.0.4",
172
172
  "typescript": "^4",
173
- "@modern-js/app-tools": "2.3.0",
174
- "@modern-js/core": "2.3.0",
175
- "@modern-js/server-core": "2.3.0",
176
- "@scripts/jest-config": "2.3.0",
177
- "@scripts/build": "2.3.0"
173
+ "@modern-js/app-tools": "2.4.0",
174
+ "@modern-js/core": "2.4.0",
175
+ "@modern-js/server-core": "2.4.0",
176
+ "@scripts/jest-config": "2.4.0",
177
+ "@scripts/build": "2.4.0"
178
178
  },
179
179
  "sideEffects": false,
180
180
  "modernConfig": {},