@teambit/react 0.0.555 → 0.0.559
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/package.json +58 -43
- package/tsconfig.json +1 -1
- package/compositions-app.tsx +0 -31
- package/highlighter-widget.tsx +0 -19
- package/index.ts +0 -9
- package/mount.tsx +0 -17
- package/package-tar/teambit-react-0.0.555.tgz +0 -0
- package/react-app-options.ts +0 -45
- package/react.app-type.ts +0 -19
- package/react.application.ts +0 -96
- package/react.aspect.ts +0 -5
- package/react.composition.tsx +0 -7
- package/react.env.ts +0 -363
- package/react.graphql.ts +0 -52
- package/react.main.runtime.ts +0 -437
- package/react.preview.runtime.ts +0 -44
- package/react.templates.ts +0 -29
- package/react.ui.runtime.tsx +0 -35
- package/templates/react-app/files/app-root.ts +0 -10
- package/templates/react-app/files/app.ts +0 -30
- package/templates/react-app/files/aspect.ts +0 -10
- package/templates/react-app/files/compositions.ts +0 -11
- package/templates/react-app/files/doc.ts +0 -29
- package/templates/react-app/files/index.ts +0 -10
- package/templates/react-app/files/main.runtime.ts +0 -22
- package/templates/react-app/index.ts +0 -47
- package/templates/react-component/files/component.ts +0 -25
- package/templates/react-component/files/composition.ts +0 -16
- package/templates/react-component/files/docs.ts +0 -32
- package/templates/react-component/files/test.ts +0 -19
- package/templates/react-component/index.ts +0 -40
- package/templates/react-component-js/files/component.ts +0 -18
- package/templates/react-component-js/files/composition.ts +0 -16
- package/templates/react-component-js/files/docs.ts +0 -32
- package/templates/react-component-js/files/test.ts +0 -21
- package/templates/react-component-js/index.ts +0 -38
- package/templates/react-context/files/composition.ts +0 -27
- package/templates/react-context/files/context-provider.ts +0 -27
- package/templates/react-context/files/context.ts +0 -21
- package/templates/react-context/files/docs.ts +0 -51
- package/templates/react-context/files/test.ts +0 -18
- package/templates/react-context/index.ts +0 -32
- package/templates/react-env/files/aspect.ts +0 -10
- package/templates/react-env/files/doc.ts +0 -163
- package/templates/react-env/files/index.ts +0 -10
- package/templates/react-env/files/jest.config.ts +0 -21
- package/templates/react-env/files/main.runtime.ts +0 -84
- package/templates/react-env/files/preview.runtime.ts +0 -27
- package/templates/react-env/files/typescript.config.ts +0 -21
- package/templates/react-env/files/webpack.config.ts +0 -48
- package/templates/react-env/index.ts +0 -51
- package/templates/react-hook/files/component.ts +0 -16
- package/templates/react-hook/files/composition.ts +0 -23
- package/templates/react-hook/files/docs.ts +0 -33
- package/templates/react-hook/files/test.ts +0 -20
- package/templates/react-hook/index.ts +0 -21
- package/templates/react-workspace/index.ts +0 -27
- package/templates/react-workspace-app/index.ts +0 -20
- package/templates/react-workspace-deprecated/index.ts +0 -28
- package/templates/react-workspace-lib/index.ts +0 -21
- package/templates/workspace-common/files/eslint-config.ts +0 -6
- package/templates/workspace-common/files/git-ignore.ts +0 -113
- package/templates/workspace-common/files/prettier-config.ts +0 -5
- package/templates/workspace-common/files/readme-file.ts +0 -36
- package/templates/workspace-common/files/ts-config.ts +0 -7
- package/templates/workspace-common/files/types/asset.ts +0 -28
- package/templates/workspace-common/files/types/style.ts +0 -43
- package/templates/workspace-common/files/workspace-config.ts +0 -58
- package/templates/workspace-common/generate-files.ts +0 -51
- package/templates/workspace-common/index.ts +0 -1
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/typescript/asset.d.ts +0 -29
- package/typescript/style.d.ts +0 -42
- package/webpack/postcss.config.ts +0 -21
- package/webpack/webpack.config.base.prod.ts +0 -123
- package/webpack/webpack.config.base.ts +0 -365
- package/webpack/webpack.config.component.dev.ts +0 -104
- package/webpack/webpack.config.component.prod.ts +0 -39
- package/webpack/webpack.config.env.dev.ts +0 -21
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.559",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/react/react",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.react",
|
|
8
8
|
"name": "react",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.559"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"react-error-boundary": "^3.0.0",
|
|
@@ -79,46 +79,46 @@
|
|
|
79
79
|
"@teambit/react.instructions.react.adding-compositions": "0.0.6",
|
|
80
80
|
"@teambit/react.instructions.react.adding-tests": "0.0.6",
|
|
81
81
|
"@teambit/design.ui.pages.standalone-not-found-page": "0.0.354",
|
|
82
|
-
"@teambit/preview": "0.0.
|
|
83
|
-
"@teambit/react.ui.error-fallback": "0.0.
|
|
84
|
-
"@teambit/react.ui.loader-fallback": "0.0.
|
|
85
|
-
"@teambit/compositions.ui.hooks.use-composition": "0.0.
|
|
82
|
+
"@teambit/preview": "0.0.559",
|
|
83
|
+
"@teambit/react.ui.error-fallback": "0.0.90",
|
|
84
|
+
"@teambit/react.ui.loader-fallback": "0.0.68",
|
|
85
|
+
"@teambit/compositions.ui.hooks.use-composition": "0.0.143",
|
|
86
86
|
"@teambit/design.ui.input.option-button": "0.0.26",
|
|
87
87
|
"@teambit/design.ui.tooltip": "0.0.352",
|
|
88
|
-
"@teambit/application": "0.0.
|
|
89
|
-
"@teambit/bundler": "0.0.
|
|
90
|
-
"@teambit/builder": "0.0.
|
|
91
|
-
"@teambit/isolator": "0.0.
|
|
92
|
-
"@teambit/toolbox.network.get-port": "0.0.
|
|
93
|
-
"@teambit/compiler": "0.0.
|
|
94
|
-
"@teambit/component.modules.component-url": "0.0.
|
|
95
|
-
"@teambit/component": "0.0.
|
|
96
|
-
"@teambit/envs": "0.0.
|
|
97
|
-
"@teambit/eslint": "0.0.
|
|
98
|
-
"@teambit/formatter": "0.0.
|
|
99
|
-
"@teambit/jest": "0.0.
|
|
100
|
-
"@teambit/linter": "0.0.
|
|
101
|
-
"@teambit/pkg": "0.0.
|
|
102
|
-
"@teambit/prettier": "0.0.
|
|
103
|
-
"@teambit/react.babel.bit-react-transformer": "0.0.
|
|
104
|
-
"@teambit/schema": "0.0.
|
|
105
|
-
"@teambit/tester": "0.0.
|
|
106
|
-
"@teambit/typescript": "0.0.
|
|
107
|
-
"@teambit/webpack": "0.0.
|
|
108
|
-
"@teambit/workspace": "0.0.
|
|
109
|
-
"@teambit/cli": "0.0.
|
|
110
|
-
"@teambit/dependency-resolver": "0.0.
|
|
111
|
-
"@teambit/generator": "0.0.
|
|
112
|
-
"@teambit/graphql": "0.0.
|
|
113
|
-
"@teambit/react.ui.highlighter-provider": "0.0.
|
|
114
|
-
"@teambit/compositions": "0.0.
|
|
115
|
-
"@teambit/ui": "0.0.
|
|
116
|
-
"@teambit/react.eslint-config-bit-react": "0.0.
|
|
117
|
-
"@teambit/mdx.modules.mdx-loader": "0.0.
|
|
118
|
-
"@teambit/webpack.modules.generate-style-loaders": "0.0.
|
|
119
|
-
"@teambit/webpack.modules.style-regexps": "0.0.
|
|
120
|
-
"@teambit/component-id": "0.0.
|
|
121
|
-
"@teambit/config": "0.0.
|
|
88
|
+
"@teambit/application": "0.0.201",
|
|
89
|
+
"@teambit/bundler": "0.0.559",
|
|
90
|
+
"@teambit/builder": "0.0.559",
|
|
91
|
+
"@teambit/isolator": "0.0.559",
|
|
92
|
+
"@teambit/toolbox.network.get-port": "0.0.93",
|
|
93
|
+
"@teambit/compiler": "0.0.559",
|
|
94
|
+
"@teambit/component.modules.component-url": "0.0.100",
|
|
95
|
+
"@teambit/component": "0.0.559",
|
|
96
|
+
"@teambit/envs": "0.0.559",
|
|
97
|
+
"@teambit/eslint": "0.0.559",
|
|
98
|
+
"@teambit/formatter": "0.0.110",
|
|
99
|
+
"@teambit/jest": "0.0.559",
|
|
100
|
+
"@teambit/linter": "0.0.559",
|
|
101
|
+
"@teambit/pkg": "0.0.559",
|
|
102
|
+
"@teambit/prettier": "0.0.110",
|
|
103
|
+
"@teambit/react.babel.bit-react-transformer": "0.0.473",
|
|
104
|
+
"@teambit/schema": "0.0.559",
|
|
105
|
+
"@teambit/tester": "0.0.559",
|
|
106
|
+
"@teambit/typescript": "0.0.559",
|
|
107
|
+
"@teambit/webpack": "0.0.559",
|
|
108
|
+
"@teambit/workspace": "0.0.559",
|
|
109
|
+
"@teambit/cli": "0.0.389",
|
|
110
|
+
"@teambit/dependency-resolver": "0.0.559",
|
|
111
|
+
"@teambit/generator": "0.0.559",
|
|
112
|
+
"@teambit/graphql": "0.0.559",
|
|
113
|
+
"@teambit/react.ui.highlighter-provider": "0.0.153",
|
|
114
|
+
"@teambit/compositions": "0.0.559",
|
|
115
|
+
"@teambit/ui": "0.0.559",
|
|
116
|
+
"@teambit/react.eslint-config-bit-react": "0.0.466",
|
|
117
|
+
"@teambit/mdx.modules.mdx-loader": "0.0.467",
|
|
118
|
+
"@teambit/webpack.modules.generate-style-loaders": "0.0.83",
|
|
119
|
+
"@teambit/webpack.modules.style-regexps": "0.0.112",
|
|
120
|
+
"@teambit/component-id": "0.0.379",
|
|
121
|
+
"@teambit/config": "0.0.400"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@types/react": "^17.0.8",
|
|
@@ -133,10 +133,10 @@
|
|
|
133
133
|
"@types/mocha": "5.2.7",
|
|
134
134
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
135
135
|
"@types/jest": "^26.0.0",
|
|
136
|
-
"@teambit/react.aspect-docs.react": "0.0.
|
|
136
|
+
"@teambit/react.aspect-docs.react": "0.0.108"
|
|
137
137
|
},
|
|
138
138
|
"peerDependencies": {
|
|
139
|
-
"@teambit/legacy": "1.0.
|
|
139
|
+
"@teambit/legacy": "1.0.175",
|
|
140
140
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
141
141
|
"react": "^16.8.0 || ^17.0.0"
|
|
142
142
|
},
|
|
@@ -198,11 +198,26 @@
|
|
|
198
198
|
"@types/jest": "^26.0.0"
|
|
199
199
|
},
|
|
200
200
|
"peerDependencies": {
|
|
201
|
-
"@teambit/legacy": "1.0.
|
|
201
|
+
"@teambit/legacy": "1.0.175",
|
|
202
202
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
203
203
|
"react": "^16.8.0 || ^17.0.0"
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
},
|
|
207
|
+
"files": [
|
|
208
|
+
"dist",
|
|
209
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
210
|
+
"**/*.md",
|
|
211
|
+
"**/*.mdx",
|
|
212
|
+
"**/*.js",
|
|
213
|
+
"**/*.json",
|
|
214
|
+
"**/*.sass",
|
|
215
|
+
"**/*.scss",
|
|
216
|
+
"**/*.less",
|
|
217
|
+
"**/*.css",
|
|
218
|
+
"**/*.css",
|
|
219
|
+
"**/*.jpeg",
|
|
220
|
+
"**/*.gif"
|
|
221
|
+
],
|
|
207
222
|
"private": false
|
|
208
223
|
}
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
package/compositions-app.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Composer } from '@teambit/base-ui.utils.composer';
|
|
3
|
-
import { StandaloneNotFoundPage } from '@teambit/design.ui.pages.standalone-not-found-page';
|
|
4
|
-
import { RenderingContext } from '@teambit/preview';
|
|
5
|
-
import { ErrorFallback } from '@teambit/react.ui.error-fallback';
|
|
6
|
-
import { LoaderFallback } from '@teambit/react.ui.loader-fallback';
|
|
7
|
-
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
|
-
import { ReactAspect } from './react.aspect';
|
|
9
|
-
|
|
10
|
-
// hide scrollbars so they won't be visible in the preview at the component card (and it's ok not to show them in the compositions page)
|
|
11
|
-
const hideScrollbars = 'body::-webkit-scrollbar {display: none;}';
|
|
12
|
-
|
|
13
|
-
export function CompositionsApp({
|
|
14
|
-
Composition,
|
|
15
|
-
previewContext,
|
|
16
|
-
}: {
|
|
17
|
-
Composition?: React.ComponentType;
|
|
18
|
-
previewContext: RenderingContext;
|
|
19
|
-
}) {
|
|
20
|
-
const reactContext = previewContext.get(ReactAspect.id);
|
|
21
|
-
const providers = reactContext?.providers || [];
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<ErrorBoundary FallbackComponent={ErrorFallback} resetKeys={[Composition]}>
|
|
25
|
-
<Composer components={providers}>
|
|
26
|
-
<style>{hideScrollbars}</style>
|
|
27
|
-
<LoaderFallback Target={Composition} DefaultComponent={StandaloneNotFoundPage} />
|
|
28
|
-
</Composer>
|
|
29
|
-
</ErrorBoundary>
|
|
30
|
-
);
|
|
31
|
-
}
|
package/highlighter-widget.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { OptionButton } from '@teambit/design.ui.input.option-button';
|
|
3
|
-
import { Tooltip } from '@teambit/design.ui.tooltip';
|
|
4
|
-
import { usePreviewQueryParams } from '@teambit/compositions.ui.hooks.use-composition';
|
|
5
|
-
|
|
6
|
-
const PARAM_NAME = 'highlighter';
|
|
7
|
-
|
|
8
|
-
export function HighlighterWidget() {
|
|
9
|
-
const [active, setActive] = usePreviewQueryParams(PARAM_NAME);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<Tooltip content="Component Highlighter (beta)">
|
|
13
|
-
{/* tooltip requires child with ref */}
|
|
14
|
-
<span>
|
|
15
|
-
<OptionButton icon="highlighter-toggle" onClick={() => setActive(!active)} active={active} />
|
|
16
|
-
</span>
|
|
17
|
-
</Tooltip>
|
|
18
|
-
);
|
|
19
|
-
}
|
package/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type { ReactMain, UseWebpackModifiers, UseTypescriptModifiers } from './react.main.runtime';
|
|
2
|
-
export type { ReactPreview } from './react.preview.runtime';
|
|
3
|
-
export type { ReactEnv } from './react.env';
|
|
4
|
-
export type { ReactAppOptions } from './react-app-options';
|
|
5
|
-
// Re-export it to indicate for people that extends the react env that we are using it
|
|
6
|
-
// Commented - make errors in safari - SyntaxError: Invalid regular expression: invalid group specifier name
|
|
7
|
-
// export * as styleRegexps from '@teambit/modules.style-regexps';
|
|
8
|
-
|
|
9
|
-
export { ReactAspect, ReactAspect as default } from './react.aspect';
|
package/mount.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { RenderingContext } from '@teambit/preview';
|
|
4
|
-
|
|
5
|
-
import { CompositionsApp } from './compositions-app';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* this mounts compositions into the DOM in the component preview.
|
|
9
|
-
* this function can be overridden through ReactAspect.overrideCompositionsMounter() API
|
|
10
|
-
* to apply custom logic for component DOM mounting.
|
|
11
|
-
*/
|
|
12
|
-
export default (Composition: React.ComponentType, previewContext: RenderingContext) => {
|
|
13
|
-
ReactDOM.render(
|
|
14
|
-
<CompositionsApp Composition={Composition} previewContext={previewContext} />,
|
|
15
|
-
document.getElementById('root')
|
|
16
|
-
);
|
|
17
|
-
};
|
|
Binary file
|
package/react-app-options.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Bundler, DevServer } from '@teambit/bundler';
|
|
2
|
-
import { DeployContext } from '@teambit/application';
|
|
3
|
-
|
|
4
|
-
export type ReactAppOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* name of the application.
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* path to entry files of the application.
|
|
12
|
-
*/
|
|
13
|
-
entry: string[];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* use server-side rendering for the app.
|
|
17
|
-
*/
|
|
18
|
-
ssr?: boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* instance of bundler to use.
|
|
22
|
-
*/
|
|
23
|
-
bundler?: Bundler;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* instance of dev server to use.
|
|
27
|
-
*/
|
|
28
|
-
devServer?: DevServer;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* deploy function.
|
|
32
|
-
*/
|
|
33
|
-
deploy?: (context: DeployContext) => Promise<void>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* prerender routes of application (will create static file for the route)
|
|
37
|
-
* e.g ['/plugins', '/learn', '/docs/quick-start]
|
|
38
|
-
*/
|
|
39
|
-
prerenderRoutes?: string[];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* ranges of ports to use to run the app server.
|
|
43
|
-
*/
|
|
44
|
-
portRange?: number[];
|
|
45
|
-
};
|
package/react.app-type.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ApplicationType } from '@teambit/application';
|
|
2
|
-
import { ReactEnv } from './react.env';
|
|
3
|
-
import { ReactAppOptions } from './react-app-options';
|
|
4
|
-
import { ReactApp } from './react.application';
|
|
5
|
-
|
|
6
|
-
export class ReactAppType implements ApplicationType<ReactAppOptions> {
|
|
7
|
-
constructor(readonly name: string, private reactEnv: ReactEnv) {}
|
|
8
|
-
|
|
9
|
-
createApp(options: ReactAppOptions) {
|
|
10
|
-
return new ReactApp(
|
|
11
|
-
options.name,
|
|
12
|
-
options.entry,
|
|
13
|
-
options.portRange || [3000, 4000],
|
|
14
|
-
this.reactEnv,
|
|
15
|
-
options.deploy,
|
|
16
|
-
options.prerenderRoutes
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
package/react.application.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import PrerenderSPAPlugin from '@dreysolano/prerender-spa-plugin';
|
|
2
|
-
import { join, basename } from 'path';
|
|
3
|
-
import { Capsule } from '@teambit/isolator';
|
|
4
|
-
import { Application, AppContext, DeployContext } from '@teambit/application';
|
|
5
|
-
import { BuildContext } from '@teambit/builder';
|
|
6
|
-
import { Bundler, BundlerContext, DevServerContext } from '@teambit/bundler';
|
|
7
|
-
import { Port } from '@teambit/toolbox.network.get-port';
|
|
8
|
-
import { ReactEnv } from './react.env';
|
|
9
|
-
|
|
10
|
-
export class ReactApp implements Application {
|
|
11
|
-
constructor(
|
|
12
|
-
readonly name: string,
|
|
13
|
-
readonly entry: string[],
|
|
14
|
-
readonly portRange: number[],
|
|
15
|
-
private reactEnv: ReactEnv,
|
|
16
|
-
readonly deploy?: (context: DeployContext) => Promise<void>,
|
|
17
|
-
readonly prerenderRoutes?: string[]
|
|
18
|
-
) {}
|
|
19
|
-
|
|
20
|
-
applicationType = 'react';
|
|
21
|
-
|
|
22
|
-
async run(context: AppContext): Promise<number> {
|
|
23
|
-
const devServerContext = this.getDevServerContext(context);
|
|
24
|
-
const devServer = this.reactEnv.getDevServer(devServerContext, [
|
|
25
|
-
(configMutator) => {
|
|
26
|
-
// configMutator.addTopLevel('output', { publicPath: `/public/${this.name}` });
|
|
27
|
-
configMutator.addTopLevel('devServer', {
|
|
28
|
-
historyApiFallback: {
|
|
29
|
-
index: '/index.html',
|
|
30
|
-
disableDotRule: true,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (!configMutator.raw.output) configMutator.raw.output = {};
|
|
35
|
-
configMutator.raw.output.publicPath = '/';
|
|
36
|
-
|
|
37
|
-
return configMutator;
|
|
38
|
-
},
|
|
39
|
-
]);
|
|
40
|
-
const [from, to] = this.portRange;
|
|
41
|
-
const port = await Port.getPort(from, to);
|
|
42
|
-
await devServer.listen(port);
|
|
43
|
-
return port;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async build(context: BuildContext, aspectId: string, appCapsule: Capsule): Promise<DeployContext> {
|
|
47
|
-
const reactEnv: ReactEnv = context.env;
|
|
48
|
-
const publicDir = join('applications', this.name, 'build');
|
|
49
|
-
const outputPath = join(appCapsule.path, publicDir);
|
|
50
|
-
const { distDir } = reactEnv.getCompiler();
|
|
51
|
-
const entries = this.entry.map((entry) => require.resolve(`${appCapsule.path}/${distDir}/${basename(entry)}`));
|
|
52
|
-
const bundlerContext: BundlerContext = Object.assign(context, {
|
|
53
|
-
targets: [
|
|
54
|
-
{
|
|
55
|
-
components: [appCapsule?.component],
|
|
56
|
-
entries,
|
|
57
|
-
outputPath,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
entry: [],
|
|
61
|
-
rootPath: '/',
|
|
62
|
-
});
|
|
63
|
-
const bundler: Bundler = await reactEnv.getBundler(bundlerContext, [
|
|
64
|
-
(configMutator) => {
|
|
65
|
-
configMutator.addTopLevel('output', { path: join(outputPath, 'public'), publicPath: `/` });
|
|
66
|
-
configMutator.addPlugin(
|
|
67
|
-
new PrerenderSPAPlugin({
|
|
68
|
-
staticDir: join(outputPath, 'public'),
|
|
69
|
-
routes: this.prerenderRoutes,
|
|
70
|
-
postProcess(renderedRoute) {
|
|
71
|
-
renderedRoute.outputPath = join(outputPath, 'public', `${renderedRoute.originalRoute}.html`);
|
|
72
|
-
return renderedRoute;
|
|
73
|
-
},
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
return configMutator;
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
await bundler.run();
|
|
80
|
-
const deployContext = Object.assign(context, {
|
|
81
|
-
applicationType: this.applicationType,
|
|
82
|
-
aspectId,
|
|
83
|
-
publicDir: join(appCapsule.path, publicDir, 'public'),
|
|
84
|
-
});
|
|
85
|
-
return deployContext;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private getDevServerContext(context: AppContext): DevServerContext {
|
|
89
|
-
return Object.assign(context, {
|
|
90
|
-
entry: this.entry,
|
|
91
|
-
rootPath: '',
|
|
92
|
-
publicPath: `public/${this.name}`,
|
|
93
|
-
title: this.name,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
package/react.aspect.ts
DELETED
package/react.composition.tsx
DELETED