ssr-plugin-react 6.2.85 → 7.0.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +63 -53
  3. package/cjs/entry/context.d.ts +0 -1
  4. package/cjs/entry/context.d.ts.map +1 -1
  5. package/cjs/entry/context.js +1 -2
  6. package/cjs/entry/context.js.map +1 -1
  7. package/cjs/entry/create.d.ts +0 -1
  8. package/cjs/entry/create.d.ts.map +1 -1
  9. package/cjs/entry/create.js +2 -2
  10. package/cjs/entry/create.js.map +1 -1
  11. package/cjs/entry/{client-entry.d.ts → react17-client-entry.d.ts} +1 -2
  12. package/cjs/entry/react17-client-entry.d.ts.map +1 -0
  13. package/cjs/entry/{client-entry.js → react17-client-entry.js} +11 -7
  14. package/cjs/entry/react17-client-entry.js.map +1 -0
  15. package/{esm/entry/client-entry.d.ts → cjs/entry/react18-client-entry.d.ts} +1 -2
  16. package/cjs/entry/react18-client-entry.d.ts.map +1 -0
  17. package/cjs/entry/react18-client-entry.js +62 -0
  18. package/cjs/entry/react18-client-entry.js.map +1 -0
  19. package/cjs/entry/server-entry.d.ts +0 -1
  20. package/cjs/entry/server-entry.d.ts.map +1 -1
  21. package/cjs/entry/server-entry.js +16 -4
  22. package/cjs/entry/server-entry.js.map +1 -1
  23. package/cjs/index.d.ts +0 -1
  24. package/cjs/index.d.ts.map +1 -1
  25. package/cjs/index.js +28 -37
  26. package/cjs/index.js.map +1 -1
  27. package/esm/entry/context.d.ts +0 -1
  28. package/esm/entry/context.d.ts.map +1 -1
  29. package/esm/entry/context.js.map +1 -1
  30. package/esm/entry/create.d.ts +0 -1
  31. package/esm/entry/create.d.ts.map +1 -1
  32. package/esm/entry/create.js.map +1 -1
  33. package/esm/entry/react17-client-entry.d.ts +3 -0
  34. package/esm/entry/react17-client-entry.d.ts.map +1 -0
  35. package/esm/entry/{client-entry.js → react17-client-entry.js} +11 -7
  36. package/esm/entry/react17-client-entry.js.map +1 -0
  37. package/esm/entry/react18-client-entry.d.ts +3 -0
  38. package/esm/entry/react18-client-entry.d.ts.map +1 -0
  39. package/esm/entry/react18-client-entry.js +59 -0
  40. package/esm/entry/react18-client-entry.js.map +1 -0
  41. package/esm/entry/server-entry.d.ts +0 -1
  42. package/esm/entry/server-entry.d.ts.map +1 -1
  43. package/esm/entry/server-entry.js +17 -5
  44. package/esm/entry/server-entry.js.map +1 -1
  45. package/esm/index.d.ts +0 -1
  46. package/esm/index.d.ts.map +1 -1
  47. package/esm/index.js +28 -22
  48. package/esm/index.js.map +1 -1
  49. package/package.json +24 -52
  50. package/src/entry/create.ts +0 -1
  51. package/src/entry/{client-entry.tsx → react17-client-entry.tsx} +37 -35
  52. package/src/entry/react18-client-entry.tsx +80 -0
  53. package/src/entry/server-entry.tsx +20 -5
  54. package/src/index.ts +30 -23
  55. package/.turbo/turbo-build.log +0 -7
  56. package/cjs/config/base.d.ts +0 -4
  57. package/cjs/config/base.d.ts.map +0 -1
  58. package/cjs/config/base.js +0 -49
  59. package/cjs/config/base.js.map +0 -1
  60. package/cjs/config/client.d.ts +0 -5
  61. package/cjs/config/client.d.ts.map +0 -1
  62. package/cjs/config/client.js +0 -54
  63. package/cjs/config/client.js.map +0 -1
  64. package/cjs/config/index.d.ts +0 -3
  65. package/cjs/config/index.d.ts.map +0 -1
  66. package/cjs/config/index.js +0 -19
  67. package/cjs/config/index.js.map +0 -1
  68. package/cjs/config/server.d.ts +0 -6
  69. package/cjs/config/server.d.ts.map +0 -1
  70. package/cjs/config/server.js +0 -39
  71. package/cjs/config/server.js.map +0 -1
  72. package/cjs/entry/client-entry.d.ts.map +0 -1
  73. package/cjs/entry/client-entry.js.map +0 -1
  74. package/cjs/tools/vite.d.ts +0 -9
  75. package/cjs/tools/vite.d.ts.map +0 -1
  76. package/cjs/tools/vite.js +0 -142
  77. package/cjs/tools/vite.js.map +0 -1
  78. package/cjs/tools/webpack.d.ts +0 -3
  79. package/cjs/tools/webpack.d.ts.map +0 -1
  80. package/cjs/tools/webpack.js +0 -23
  81. package/cjs/tools/webpack.js.map +0 -1
  82. package/esm/config/base.d.ts +0 -4
  83. package/esm/config/base.d.ts.map +0 -1
  84. package/esm/config/base.js +0 -46
  85. package/esm/config/base.js.map +0 -1
  86. package/esm/config/client.d.ts +0 -5
  87. package/esm/config/client.d.ts.map +0 -1
  88. package/esm/config/client.js +0 -51
  89. package/esm/config/client.js.map +0 -1
  90. package/esm/config/index.d.ts +0 -3
  91. package/esm/config/index.d.ts.map +0 -1
  92. package/esm/config/index.js +0 -3
  93. package/esm/config/index.js.map +0 -1
  94. package/esm/config/server.d.ts +0 -6
  95. package/esm/config/server.d.ts.map +0 -1
  96. package/esm/config/server.js +0 -36
  97. package/esm/config/server.js.map +0 -1
  98. package/esm/entry/client-entry.d.ts.map +0 -1
  99. package/esm/entry/client-entry.js.map +0 -1
  100. package/esm/tools/vite.d.ts +0 -9
  101. package/esm/tools/vite.d.ts.map +0 -1
  102. package/esm/tools/vite.js +0 -134
  103. package/esm/tools/vite.js.map +0 -1
  104. package/esm/tools/webpack.d.ts +0 -3
  105. package/esm/tools/webpack.d.ts.map +0 -1
  106. package/esm/tools/webpack.js +0 -18
  107. package/esm/tools/webpack.js.map +0 -1
  108. package/src/config/base.ts +0 -57
  109. package/src/config/client.ts +0 -62
  110. package/src/config/index.ts +0 -2
  111. package/src/config/server.ts +0 -43
  112. package/src/tools/vite.ts +0 -134
  113. package/src/tools/webpack.ts +0 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssr-plugin-react",
3
- "version": "6.2.85",
3
+ "version": "7.0.1",
4
4
  "description": "plugin-react for ssr",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -30,64 +30,36 @@
30
30
  },
31
31
  "homepage": "https://github.com/zhangyuang/ssr#readme",
32
32
  "dependencies": {
33
- "@babel/core": "^7.0.0",
34
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
35
- "@babel/plugin-proposal-optional-chaining": "^7.16.5",
36
- "@babel/plugin-proposal-private-methods": "^7.18.6",
37
- "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
38
- "@babel/plugin-transform-runtime": "^7.9.6",
39
- "@babel/preset-env": "^7.5.5",
40
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
41
- "@types/semver": "^7.3.13",
42
- "@vitejs/plugin-react": "^1.3.2",
43
- "babel-loader": "^8.0.4",
44
- "babel-plugin-import": "1.13.3",
33
+ "ssr-common-utils": "^7.0.0",
34
+ "@vitejs/plugin-react-oxc": "^0.3.0",
35
+ "@vitejs/plugin-react": "^4.0.0",
45
36
  "babel-preset-react-app": "^10.0.0",
46
- "core-js": "^3.6.4",
47
- "css-loader": "^5.2.7",
48
- "file-loader": "^6.2.0",
49
- "less": "^4.1.1",
50
- "less-loader": "^7.3.0",
51
- "optimize-css-assets-webpack-plugin": "^6.0.0",
52
- "ora": "^4.0.4",
53
- "postcss": "^8.0.0",
54
- "postcss-discard-comments": "^5.0.0",
55
- "postcss-flexbugs-fixes": "^5.0.0",
56
- "postcss-loader": "^4.0.0",
57
- "postcss-modules": "^4.0.0",
58
- "postcss-preset-env": "7.6.0",
59
- "postcss-safe-parser": "^6.0.0",
60
- "react": "^17.0.1",
61
- "react-dev-utils": "^11.0.4",
62
- "react-dom": "^17.0.0",
63
- "react-refresh": "^0.12.0",
64
- "react-router": "^5.2.1",
65
- "react-router-dom": "^5.1.2",
66
- "rollup-plugin-visualizer": "^5.12.0",
67
- "semver": "^7.3.8",
68
- "ssr-common-utils": "^6.0.0",
69
- "ssr-deepclone": "^1.0.0",
70
- "ssr-hoc-react": "^6.2.7",
71
- "ssr-mini-css-extract-plugin": "^1.6.5",
72
- "ssr-serialize-javascript": "^6.0.0",
73
- "ssr-vite-plugin-style-import": "^2.0.1",
74
- "ssr-webpack": "^6.2.10",
75
- "ssr-webpack4": "^4.46.2",
76
- "terser-webpack-plugin": "^2.3.5",
77
- "url-loader": "^4.1.1",
78
- "valtio": "^1.11.2",
79
- "vite": "^2.9.15",
80
- "webpack-bundle-analyzer": "^3.6.1",
81
- "webpack-chain": "^6.4.0",
82
- "webpack-manifest-plugin": "^2.2.0",
83
- "webpackbar": "^5.0.0-3"
37
+ "ssr-hoc-react": "^7.0.0",
38
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
39
+ "valtio": "^1.13.2"
40
+ },
41
+ "peerDependencies": {
42
+ "react": ">=17.0.1",
43
+ "react-dom": ">=17.0.0",
44
+ "react-router": "^5.1.8",
45
+ "react-router-dom": "^5.0.0",
46
+ "webpack": "^4.0.0"
84
47
  },
85
48
  "devDependencies": {
49
+ "@types/react18": "npm:@types/react@^18.0.0",
50
+ "@types/react-dom18": "npm:@types/react-dom@^18.0.0",
86
51
  "@types/react": "^17.0.0",
87
52
  "@types/react-dom": "^17.0.0",
88
53
  "@types/react-router-dom": "^5.1.3",
89
54
  "@types/webpack": "^4.41.10",
90
55
  "concurrently": "^5.1.0",
91
- "ssr-types": "^6.2.7"
56
+ "ssr-types": "workspace:*",
57
+ "ssr-webpack": "workspace:*",
58
+ "ssr-vite": "workspace:*"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "webpack": {
62
+ "optional": true
63
+ }
92
64
  }
93
65
  }
@@ -8,7 +8,6 @@ import { ReactRoutesType } from 'ssr-types'
8
8
  import { proxy } from 'valtio'
9
9
 
10
10
  export const Routes = combineRoutes(declareRoutes, ManualRoutes) as ReactRoutesType
11
-
12
11
  export const ssrCreateContext = () => {
13
12
  const STORE_CONTEXT = createContext<IContext>({
14
13
  state: {}
@@ -1,10 +1,9 @@
1
+ import type { LayoutProps } from 'ssr-types'
2
+ import ReactDOM from 'react-dom'
1
3
  import { createElement } from 'react'
2
- import * as ReactDOM from 'react-dom'
3
- import 'react-router' // for vite prebundle list
4
4
  import { BrowserRouter, Route, Switch } from 'react-router-dom'
5
5
  import { preloadComponent, isMicro, setStoreContext, setStore } from 'ssr-common-utils'
6
6
  import { wrapComponent } from 'ssr-hoc-react'
7
- import { LayoutProps } from 'ssr-types'
8
7
  import { ssrCreateContext, Routes, createStore } from './create'
9
8
  import { AppContext } from './context'
10
9
 
@@ -22,45 +21,48 @@ const clientRender = async (): Promise<void> => {
22
21
  setStore(store ?? {})
23
22
  const baseName = isMicro() ? window.clientPrefix : window.prefix
24
23
  const routes = await preloadComponent(FeRoutes, baseName)
25
- ReactDOM[window.__USE_SSR__ ? 'hydrate' : 'render'](
26
- createElement(
27
- BrowserRouter,
28
- {
29
- basename: baseName
30
- },
31
- createElement(AppContext, {
32
- context,
33
- children: createElement(
34
- Switch,
24
+ const container = document.querySelector(window.ssrDevInfo.rootId ?? '#app')!
25
+ const ele = createElement(
26
+ //@ts-ignore
27
+ BrowserRouter,
28
+ {
29
+ basename: baseName
30
+ },
31
+ createElement(AppContext, {
32
+ context,
33
+ children: createElement(
34
+ Switch,
35
+ null,
36
+ createElement(
37
+ IApp as any,
35
38
  null,
36
39
  createElement(
37
- IApp as any,
40
+ Switch,
38
41
  null,
39
- createElement(
40
- Switch,
41
- null,
42
- routes.map((item) => {
43
- const { fetch, component, path } = item
44
- component.fetch = fetch
45
- component.layoutFetch = layoutFetch
46
- const WrappedComponent = wrapComponent(component)
47
- return createElement(Route, {
48
- exact: true,
49
- key: path,
50
- path: path,
51
- render: () =>
52
- createElement(WrappedComponent, {
53
- key: location.pathname
54
- })
55
- })
42
+ routes.map((item) => {
43
+ const { fetch, component, path } = item
44
+ component.fetch = fetch
45
+ component.layoutFetch = layoutFetch
46
+ const WrappedComponent = wrapComponent(component)
47
+ return createElement(Route, {
48
+ exact: true,
49
+ key: path,
50
+ path: path,
51
+ render: (props) =>
52
+ createElement(WrappedComponent, {
53
+ ...props,
54
+ key: props.history.location.key
55
+ })
56
56
  })
57
- )
57
+ })
58
58
  )
59
59
  )
60
- })
61
- ),
62
- document.querySelector(window.ssrDevInfo.rootId ?? '#app')
60
+ )
61
+ })
63
62
  )
63
+
64
+ ReactDOM[window.__USE_SSR__ ? 'hydrate' : 'render'](ele, container)
65
+
64
66
  if (!window.__USE_VITE__) {
65
67
  ;(module as any)?.hot?.accept?.()
66
68
  }
@@ -0,0 +1,80 @@
1
+ import type { hydrateRoot as HydrateRoot, createRoot as CreateRoot } from 'react-dom18/client'
2
+ import type { LayoutProps } from 'ssr-types'
3
+
4
+ //@ts-ignore
5
+ import { hydrateRoot, createRoot } from 'react-dom/client'
6
+ import { createElement } from 'react'
7
+ import { BrowserRouter, Route, Switch } from 'react-router-dom'
8
+ import { preloadComponent, isMicro, setStoreContext, setStore } from 'ssr-common-utils'
9
+ import { wrapComponent } from 'ssr-hoc-react'
10
+ import { ssrCreateContext, Routes, createStore } from './create'
11
+ import { AppContext } from './context'
12
+
13
+ const { FeRoutes, layoutFetch, App } = Routes
14
+
15
+ const clientRender = async (): Promise<void> => {
16
+ const IApp =
17
+ App ??
18
+ function (props: LayoutProps) {
19
+ return props.children!
20
+ }
21
+ const context = ssrCreateContext() as any
22
+ setStoreContext(context)
23
+ const store = createStore(window.__VALTIO_DATA__)
24
+ setStore(store ?? {})
25
+ const baseName = isMicro() ? window.clientPrefix : window.prefix
26
+ const routes = await preloadComponent(FeRoutes, baseName)
27
+ const container = document.querySelector(window.ssrDevInfo.rootId ?? '#app')!
28
+ const ele = createElement(
29
+ //@ts-ignore
30
+ BrowserRouter,
31
+ {
32
+ basename: baseName
33
+ },
34
+ createElement(AppContext, {
35
+ context,
36
+ children: createElement(
37
+ Switch,
38
+ null,
39
+ createElement(
40
+ IApp as any,
41
+ null,
42
+ createElement(
43
+ Switch,
44
+ null,
45
+ routes.map((item) => {
46
+ const { fetch, component, path } = item
47
+ component.fetch = fetch
48
+ component.layoutFetch = layoutFetch
49
+ const WrappedComponent = wrapComponent(component)
50
+ return createElement(Route, {
51
+ exact: true,
52
+ key: path,
53
+ path: path,
54
+ render: (props) =>
55
+ createElement(WrappedComponent, {
56
+ ...props,
57
+ key: props.history.location.key
58
+ })
59
+ })
60
+ })
61
+ )
62
+ )
63
+ )
64
+ })
65
+ )
66
+ if (window.__USE_SSR__) {
67
+ ;(hydrateRoot as typeof HydrateRoot)(container, ele)
68
+ } else {
69
+ const root = (createRoot as typeof CreateRoot)(container)
70
+ root.render(ele)
71
+ }
72
+
73
+ if (!window.__USE_VITE__) {
74
+ ;(module as any)?.hot?.accept?.()
75
+ }
76
+ }
77
+
78
+ clientRender()
79
+
80
+ export { clientRender }
@@ -1,9 +1,10 @@
1
+ import type { renderToPipeableStream } from 'react-dom18/server'
1
2
  import { PassThrough } from 'stream'
2
3
  import * as React from 'react'
3
4
  import { createElement } from 'react'
5
+ import * as ReactDOMServer from 'react-dom/server'
4
6
  import { StaticRouter } from 'react-router-dom'
5
- import { renderToString, renderToNodeStream } from 'react-dom/server'
6
- import { findRoute, getManifest, logGreen, normalizePath, getAsyncCssChunk, getAsyncJsChunk, splitPageInfo, reactRefreshFragment, localStorageWrapper, checkRoute, useStore } from 'ssr-common-utils'
7
+ import { findRoute, getManifest, logGreen, normalizePath, getAsyncCssChunk, getAsyncJsChunk, splitPageInfo, reactRefreshFragment, localStorageWrapper, checkRoute, useStore, isReact18, getClientEntry } from 'ssr-common-utils'
7
8
  import { ISSRContext, IConfig, ReactESMPreloadFeRouteItem, DynamicFC, StaticFC } from 'ssr-types'
8
9
  import { serialize } from 'ssr-serialize-javascript'
9
10
  import { AppContext } from './context'
@@ -11,9 +12,12 @@ import { Routes, ssrCreateContext, createStore } from './create'
11
12
 
12
13
  const { FeRoutes, layoutFetch, state, Layout } = Routes
13
14
 
15
+ type ReactDOMServerType = typeof ReactDOMServer & {
16
+ renderToPipeableStream: typeof renderToPipeableStream
17
+ }
14
18
  const serverRender = async (ctx: ISSRContext, config: IConfig) => {
15
19
  const context = ssrCreateContext()
16
- const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, stream, rootId, hashRouter, streamHighWaterMark } = config
20
+ const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, onReady, onError, stream, rootId, hashRouter, streamHighWaterMark } = config
17
21
  const rawPath = ctx.request.path ?? ctx.request.url
18
22
  const path = normalizePath(rawPath, prefix)
19
23
  const routeItem = findRoute<ReactESMPreloadFeRouteItem>(FeRoutes, path)
@@ -61,7 +65,7 @@ const serverRender = async (ctx: ISSRContext, config: IConfig) => {
61
65
  />
62
66
  ]
63
67
  : []),
64
- ...(isVite && isDev ? [<script type="module" src="/node_modules/ssr-plugin-react/esm/entry/client-entry.js" key="vite-react-entry" />] : []),
68
+ ...(isVite && isDev ? [<script type="module" src={`/node_modules/ssr-plugin-react/esm/entry/${getClientEntry()}.js`} key="vite-react-entry" />] : []),
65
69
  ...dynamicJsOrder
66
70
  .map((js) => manifest[js])
67
71
  .filter(Boolean)
@@ -124,7 +128,18 @@ const serverRender = async (ctx: ISSRContext, config: IConfig) => {
124
128
  })
125
129
  )
126
130
  // for ctx.body will loose asynclocalstorage context, consume stream in advance like vue2/3
127
- return stream ? renderToNodeStream(ele).pipe(new PassThrough({ highWaterMark: streamHighWaterMark })) : renderToString(ele)
131
+ if (isReact18()) {
132
+ return stream
133
+ ? (ReactDOMServer as ReactDOMServerType)
134
+ .renderToPipeableStream(ele, {
135
+ onAllReady: onReady,
136
+ onError: onError as any
137
+ })
138
+ .pipe(new PassThrough({ highWaterMark: streamHighWaterMark }))
139
+ : ReactDOMServer.renderToString(ele)
140
+ } else {
141
+ return stream ? ReactDOMServer.renderToNodeStream(ele).pipe(new PassThrough({ highWaterMark: streamHighWaterMark })) : ReactDOMServer.renderToString(ele)
142
+ }
128
143
  }
129
144
 
130
145
  return await localStorageWrapper.run(
package/src/index.ts CHANGED
@@ -1,49 +1,56 @@
1
- import { loadConfig } from 'ssr-common-utils'
1
+ import { resolve } from 'path'
2
+ import { loadConfig, getCwd } from 'ssr-common-utils'
2
3
 
3
- const { isVite, optimize } = loadConfig()
4
+ const { tool, optimize } = loadConfig()
4
5
  const spinner = require('ora')('Building')
5
6
 
6
7
  export function clientPlugin() {
8
+ const cwd = getCwd()
9
+ const webpackPath = resolve(cwd, './node_modules/ssr-webpack')
10
+ const vitePath = resolve(cwd, './node_modules/ssr-vite')
11
+ const rspackPath = resolve(cwd, './node_modules/ssr-rspack')
7
12
  return {
8
13
  name: 'plugin-react',
9
14
  start: async () => {
10
- if (isVite) {
11
- const { viteStart } = await import('./tools/vite')
12
- await viteStart()
15
+ if (tool === 'vite') {
16
+ const { start } = await import(vitePath)
17
+ await start()
13
18
  } else {
14
19
  if (optimize) {
15
20
  spinner.start()
16
- const { viteBuildClient } = await import('./tools/vite')
21
+ const { viteBuildClient } = await import(vitePath)
17
22
  await viteBuildClient()
18
23
  process.env.NODE_ENV = 'development'
19
24
  spinner.stop()
20
- const { webpackStart } = await import('./tools/webpack')
21
- await webpackStart()
22
- } else {
23
- const { webpackStart } = await import('./tools/webpack')
24
- await webpackStart()
25
25
  }
26
+ if (tool === 'rspack') {
27
+ const { start } = await import(rspackPath)
28
+ await start()
29
+ return
30
+ }
31
+ const { start } = await import(webpackPath)
32
+ await start()
26
33
  }
27
34
  },
28
35
  build: async () => {
29
- if (isVite) {
30
- const { viteBuild } = await import('./tools/vite')
31
- await viteBuild()
36
+ if (tool === 'vite') {
37
+ const { build } = await import(vitePath)
38
+ await build()
32
39
  } else {
33
40
  if (optimize) {
34
41
  spinner.start()
35
- const { viteBuildClient } = await import('./tools/vite')
36
- await viteBuildClient()
42
+ const { build } = await import(vitePath)
43
+ await build()
37
44
  spinner.stop()
38
- const { webpackBuild } = await import('./tools/webpack')
39
- await webpackBuild()
40
- } else {
41
- const { webpackBuild } = await import('./tools/webpack')
42
- await webpackBuild()
43
45
  }
46
+ if (tool === 'rspack') {
47
+ const { build } = await import(rspackPath)
48
+ await build()
49
+ return
50
+ }
51
+ const { build } = await import(webpackPath)
52
+ await build()
44
53
  }
45
54
  }
46
55
  }
47
56
  }
48
-
49
- export * from './tools/vite'
@@ -1,7 +0,0 @@
1
- ssr-plugin-react:build: cache hit, replaying output 05e3f8dd6c2ab3ee
2
- ssr-plugin-react:build:
3
- ssr-plugin-react:build: > ssr-plugin-react@6.2.85 build /home/runner/work/ssr/ssr/packages/plugin-react
4
- ssr-plugin-react:build: > concurrently "tsc -p ./tsconfig.cjs.json " " tsc -p ./tsconfig.esm.json"
5
- ssr-plugin-react:build:
6
- ssr-plugin-react:build: [1] tsc -p ./tsconfig.esm.json exited with code 0
7
- ssr-plugin-react:build: [0] tsc -p ./tsconfig.cjs.json exited with code 0
@@ -1,4 +0,0 @@
1
- import WebpackChain from 'webpack-chain';
2
- declare const getBaseConfig: (chain: WebpackChain, isServer: boolean) => import("ssr-types").IConfig;
3
- export { getBaseConfig };
4
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/config/base.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,MAAM,eAAe,CAAA;AAKxC,QAAA,MAAM,aAAa,UAAW,YAAY,YAAY,OAAO,gCA6C5D,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBaseConfig = void 0;
4
- const path_1 = require("path");
5
- const ssr_common_utils_1 = require("ssr-common-utils");
6
- const webpack = require("ssr-webpack4");
7
- const MiniCssExtractPlugin = require((0, ssr_common_utils_1.loadModuleFromFramework)('ssr-mini-css-extract-plugin'));
8
- const WebpackBar = require('webpackbar');
9
- const getBaseConfig = (chain, isServer) => {
10
- const config = (0, ssr_common_utils_1.loadConfig)();
11
- const { moduleFileExtensions, chainBaseConfig, alias, define } = config;
12
- const mode = process.env.NODE_ENV;
13
- chain.mode(mode);
14
- chain.module.strictExportPresence(true);
15
- chain.resolve.modules.add('node_modules').add((0, path_1.join)((0, ssr_common_utils_1.getCwd)(), './node_modules')).end().extensions.merge(moduleFileExtensions).end().alias.end();
16
- alias &&
17
- Object.keys(alias).forEach((item) => {
18
- chain.resolve.alias.set(item, alias[item]);
19
- });
20
- (0, ssr_common_utils_1.addCommonChain)(chain, isServer);
21
- (0, ssr_common_utils_1.setStyle)(chain, /\.css$/, {
22
- rule: 'css',
23
- isServer,
24
- importLoaders: 1
25
- });
26
- (0, ssr_common_utils_1.setStyle)(chain, /\.less$/, {
27
- rule: 'less',
28
- loader: 'less-loader',
29
- isServer,
30
- importLoaders: 2
31
- });
32
- chain.plugin('minify-css').use(MiniCssExtractPlugin, (0, ssr_common_utils_1.getBuildConfig)().cssBuildConfig);
33
- chain.plugin('webpackBar').use(new WebpackBar({
34
- name: isServer ? 'server' : 'client',
35
- color: isServer ? '#f173ac' : '#45b97c'
36
- }));
37
- chain.plugin('ssrDefine').use(webpack.DefinePlugin, [
38
- {
39
- ...process.env,
40
- __isBrowser__: !isServer,
41
- ...(isServer ? define === null || define === void 0 ? void 0 : define.server : define === null || define === void 0 ? void 0 : define.client),
42
- ...define === null || define === void 0 ? void 0 : define.base
43
- }
44
- ]);
45
- chainBaseConfig(chain, isServer);
46
- return config;
47
- };
48
- exports.getBaseConfig = getBaseConfig;
49
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/config/base.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,uDAAwH;AAExH,wCAAuC;AAGvC,MAAM,oBAAoB,GAAG,OAAO,CAAC,IAAA,0CAAuB,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAC5F,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAExC,MAAM,aAAa,GAAG,CAAC,KAAmB,EAAE,QAAiB,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,IAAA,6BAAU,GAAE,CAAA;IAC3B,MAAM,EAAE,oBAAoB,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACvE,MAAM,IAAI,GAAG,OAAO,CAA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,QAAQ;QACpC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;KACvC,CAAC,CACF,CAAA;IACD,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE;QACnD;YACC,GAAG,OAAO,CAAC,GAAG;YACd,aAAa,EAAE,CAAC,QAAQ;YACxB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC;YAC/C,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI;SACf;KACD,CAAC,CAAA;IACF,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAChC,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAEQ,sCAAa"}
@@ -1,5 +0,0 @@
1
- /// <reference types="webpack" />
2
- import WebpackChain from 'webpack-chain';
3
- declare const getClientWebpack: (chain: WebpackChain) => import("webpack").Configuration;
4
- export { getClientWebpack };
5
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/config/client.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AAQxC,QAAA,MAAM,gBAAgB,UAAW,YAAY,oCAkD5C,CAAA;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClientWebpack = void 0;
4
- const ssr_common_utils_1 = require("ssr-common-utils");
5
- const base_1 = require("./base");
6
- const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
7
- const safePostCssParser = require('postcss-safe-parser');
8
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
9
- const loadModule = ssr_common_utils_1.loadModuleFromFramework;
10
- const getClientWebpack = (chain) => {
11
- const { isDev, chunkName, getOutput, cwd, chainClientConfig, host, fePort } = (0, ssr_common_utils_1.loadConfig)();
12
- const buildConfig = (0, ssr_common_utils_1.getBuildConfig)();
13
- const shouldUseSourceMap = isDev || Boolean(process.env.GENERATE_SOURCEMAP);
14
- const publicPath = (0, ssr_common_utils_1.getOutputPublicPath)();
15
- (0, base_1.getBaseConfig)(chain, false);
16
- chain.entry(chunkName).add(require.resolve('../entry/client-entry')).end().output.path(getOutput().clientOutPut).filename(buildConfig.jsBuldConfig.fileName).chunkFilename(buildConfig.jsBuldConfig.chunkFileName).publicPath(publicPath).end();
17
- chain.optimization
18
- .runtimeChunk(true)
19
- .splitChunks((0, ssr_common_utils_1.getSplitChunksOptions)(ssr_common_utils_1.asyncChunkMap))
20
- .when(!isDev, (optimization) => {
21
- optimization.minimizer('terser').use(loadModule('terser-webpack-plugin'), [(0, ssr_common_utils_1.terserConfig)(false)]);
22
- optimization.minimizer('optimize-css').use(loadModule('optimize-css-assets-webpack-plugin'), [
23
- {
24
- cssProcessorOptions: {
25
- parser: safePostCssParser,
26
- map: shouldUseSourceMap
27
- ? {
28
- inline: false,
29
- annotation: true
30
- }
31
- : false
32
- }
33
- }
34
- ]);
35
- });
36
- chain.plugin('moduleNotFound').use(ModuleNotFoundPlugin, [cwd]);
37
- chain.plugin('manifest').use(loadModule('webpack-manifest-plugin'), [
38
- {
39
- fileName: 'asset-manifest.json'
40
- }
41
- ]);
42
- chain.when(isDev, (chain) => {
43
- chain.plugin('fast-refresh').use(new ReactRefreshWebpackPlugin({
44
- overlay: {
45
- sockHost: host,
46
- sockPort: fePort
47
- }
48
- }));
49
- });
50
- chainClientConfig(chain); // 合并用户自定义配置
51
- return chain.toConfig();
52
- };
53
- exports.getClientWebpack = getClientWebpack;
54
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources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
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./client"), exports);
18
- __exportStar(require("./server"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,2CAAwB"}
@@ -1,6 +0,0 @@
1
- /// <reference types="webpack" />
2
- import * as webpack from 'ssr-webpack4';
3
- import WebpackChain from 'webpack-chain';
4
- declare const getServerWebpack: (chain: WebpackChain) => webpack.Configuration;
5
- export { getServerWebpack };
6
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/config/server.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,YAAY,MAAM,eAAe,CAAA;AAIxC,QAAA,MAAM,gBAAgB,UAAW,YAAY,0BAkC5C,CAAA;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getServerWebpack = void 0;
4
- const ssr_common_utils_1 = require("ssr-common-utils");
5
- const webpack = require("ssr-webpack4");
6
- const base_1 = require("./base");
7
- const getServerWebpack = (chain) => {
8
- const config = (0, ssr_common_utils_1.loadConfig)();
9
- const { isDev, getOutput, chainServerConfig, chunkName } = config;
10
- const shouldUseSourceMap = isDev || Boolean(process.env.GENERATE_SOURCEMAP);
11
- (0, base_1.getBaseConfig)(chain, true);
12
- chain.target('node');
13
- chain.entry(chunkName).add(require.resolve('../entry/server-entry')).end().output.path(getOutput().serverOutPut).filename('[name].server.js').libraryTarget('commonjs');
14
- if (!isDev) {
15
- chain.optimization.minimizer('terser').use((0, ssr_common_utils_1.loadModuleFromFramework)('terser-webpack-plugin'), [
16
- {
17
- terserOptions: {
18
- keep_fnames: true
19
- },
20
- extractComments: false,
21
- parallel: true,
22
- cache: true,
23
- sourceMap: shouldUseSourceMap
24
- }
25
- ]);
26
- }
27
- chain.when(isDev, () => {
28
- chain.watch(true);
29
- });
30
- chain.plugin('serverLimit').use(webpack.optimize.LimitChunkCountPlugin, [
31
- {
32
- maxChunks: 1
33
- }
34
- ]);
35
- chainServerConfig(chain); // 合并用户自定义配置
36
- return chain.toConfig();
37
- };
38
- exports.getServerWebpack = getServerWebpack;
39
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/config/server.ts"],"names":[],"mappings":";;;AAAA,uDAAsE;AACtE,wCAAuC;AAGvC,iCAAsC;AAEtC,MAAM,gBAAgB,GAAG,CAAC,KAAmB,EAAE,EAAE;IAChD,MAAM,MAAM,GAAG,IAAA,6BAAU,GAAE,CAAA;IAC3B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IACjE,MAAM,kBAAkB,GAAG,KAAK,IAAI,OAAO,C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