@teambit/react 0.0.555 → 0.0.556
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 +49 -43
- package/compositions-app.tsx +0 -31
- package/eslint/eslintrc.js +0 -12
- package/highlighter-widget.tsx +0 -19
- package/index.ts +0 -9
- package/jest/css-transform.js +0 -12
- package/jest/file-transform.js +0 -38
- package/jest/jest.config.js +0 -30
- package/jest/setupTests.js +0 -7
- package/jest/transformer.js +0 -41
- package/mount.tsx +0 -17
- package/package-tar/teambit-react-0.0.555.tgz +0 -0
- package/prettier/prettier.config.js +0 -5
- 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.docs.mdx +0 -8
- 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/tsconfig.json +0 -34
- 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/typescript/tsconfig.build.json +0 -22
- package/typescript/tsconfig.json +0 -18
- package/webpack/format-webpack-messages.js +0 -102
- package/webpack/launch-editor-endpoint.js +0 -8
- package/webpack/postcss.config.ts +0 -21
- package/webpack/react-hot-dev-client.js +0 -274
- package/webpack/refresh.js +0 -16
- 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.556",
|
|
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.556"
|
|
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.556",
|
|
83
|
+
"@teambit/react.ui.error-fallback": "0.0.88",
|
|
84
|
+
"@teambit/react.ui.loader-fallback": "0.0.66",
|
|
85
|
+
"@teambit/compositions.ui.hooks.use-composition": "0.0.141",
|
|
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.198",
|
|
89
|
+
"@teambit/bundler": "0.0.556",
|
|
90
|
+
"@teambit/builder": "0.0.556",
|
|
91
|
+
"@teambit/isolator": "0.0.556",
|
|
92
|
+
"@teambit/toolbox.network.get-port": "0.0.91",
|
|
93
|
+
"@teambit/compiler": "0.0.556",
|
|
94
|
+
"@teambit/component.modules.component-url": "0.0.98",
|
|
95
|
+
"@teambit/component": "0.0.556",
|
|
96
|
+
"@teambit/envs": "0.0.556",
|
|
97
|
+
"@teambit/eslint": "0.0.556",
|
|
98
|
+
"@teambit/formatter": "0.0.107",
|
|
99
|
+
"@teambit/jest": "0.0.556",
|
|
100
|
+
"@teambit/linter": "0.0.556",
|
|
101
|
+
"@teambit/pkg": "0.0.556",
|
|
102
|
+
"@teambit/prettier": "0.0.107",
|
|
103
|
+
"@teambit/react.babel.bit-react-transformer": "0.0.471",
|
|
104
|
+
"@teambit/schema": "0.0.556",
|
|
105
|
+
"@teambit/tester": "0.0.556",
|
|
106
|
+
"@teambit/typescript": "0.0.556",
|
|
107
|
+
"@teambit/webpack": "0.0.556",
|
|
108
|
+
"@teambit/workspace": "0.0.556",
|
|
109
|
+
"@teambit/cli": "0.0.387",
|
|
110
|
+
"@teambit/dependency-resolver": "0.0.556",
|
|
111
|
+
"@teambit/generator": "0.0.556",
|
|
112
|
+
"@teambit/graphql": "0.0.556",
|
|
113
|
+
"@teambit/react.ui.highlighter-provider": "0.0.151",
|
|
114
|
+
"@teambit/compositions": "0.0.556",
|
|
115
|
+
"@teambit/ui": "0.0.556",
|
|
116
|
+
"@teambit/react.eslint-config-bit-react": "0.0.464",
|
|
117
|
+
"@teambit/mdx.modules.mdx-loader": "0.0.465",
|
|
118
|
+
"@teambit/webpack.modules.generate-style-loaders": "0.0.81",
|
|
119
|
+
"@teambit/webpack.modules.style-regexps": "0.0.110",
|
|
120
|
+
"@teambit/component-id": "0.0.377",
|
|
121
|
+
"@teambit/config": "0.0.398"
|
|
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.106"
|
|
137
137
|
},
|
|
138
138
|
"peerDependencies": {
|
|
139
|
-
"@teambit/legacy": "1.0.
|
|
139
|
+
"@teambit/legacy": "1.0.173",
|
|
140
140
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
141
141
|
"react": "^16.8.0 || ^17.0.0"
|
|
142
142
|
},
|
|
@@ -198,11 +198,17 @@
|
|
|
198
198
|
"@types/jest": "^26.0.0"
|
|
199
199
|
},
|
|
200
200
|
"peerDependencies": {
|
|
201
|
-
"@teambit/legacy": "1.0.
|
|
201
|
+
"@teambit/legacy": "1.0.173",
|
|
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
|
+
"README.md",
|
|
211
|
+
"README.mdx"
|
|
212
|
+
],
|
|
207
213
|
"private": false
|
|
208
214
|
}
|
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/eslint/eslintrc.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Using object
|
|
2
|
-
import '@teambit/react.eslint-config-bit-react';
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
extends: [require.resolve('@teambit/react.eslint-config-bit-react')],
|
|
6
|
-
parserOptions: {
|
|
7
|
-
// parser: require.resolve('@typescript-eslint/parser'),
|
|
8
|
-
// createDefaultProgram: true,
|
|
9
|
-
// resolve the env tsconfig.
|
|
10
|
-
project: require.resolve('../typescript/tsconfig.json'),
|
|
11
|
-
},
|
|
12
|
-
};
|
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/jest/css-transform.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// This is a custom Jest transformer turning style imports into empty objects.
|
|
2
|
-
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
process() {
|
|
6
|
-
return 'module.exports = {};';
|
|
7
|
-
},
|
|
8
|
-
getCacheKey() {
|
|
9
|
-
// The output is always the same.
|
|
10
|
-
return 'cssTransform';
|
|
11
|
-
},
|
|
12
|
-
};
|
package/jest/file-transform.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const camelcase = require('camelcase');
|
|
3
|
-
|
|
4
|
-
// This is a custom Jest transformer turning file imports into filenames.
|
|
5
|
-
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
process(src, filename) {
|
|
9
|
-
const assetFilename = JSON.stringify(path.basename(filename));
|
|
10
|
-
|
|
11
|
-
if (filename.match(/\.svg$/)) {
|
|
12
|
-
// Based on how SVGR generates a component name:
|
|
13
|
-
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
|
|
14
|
-
const pascalCaseFilename = camelcase(path.parse(filename).name, {
|
|
15
|
-
pascalCase: true,
|
|
16
|
-
});
|
|
17
|
-
const componentName = `Svg${pascalCaseFilename}`;
|
|
18
|
-
return `const React = require('react');
|
|
19
|
-
module.exports = {
|
|
20
|
-
__esModule: true,
|
|
21
|
-
default: ${assetFilename},
|
|
22
|
-
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
|
|
23
|
-
return {
|
|
24
|
-
$$typeof: Symbol.for('react.element'),
|
|
25
|
-
type: 'svg',
|
|
26
|
-
ref: ref,
|
|
27
|
-
key: null,
|
|
28
|
-
props: Object.assign({}, props, {
|
|
29
|
-
children: ${assetFilename}
|
|
30
|
-
})
|
|
31
|
-
};
|
|
32
|
-
}),
|
|
33
|
-
};`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return `module.exports = ${assetFilename};`;
|
|
37
|
-
},
|
|
38
|
-
};
|
package/jest/jest.config.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// "roots": [
|
|
3
|
-
// "<rootDir>/src"
|
|
4
|
-
// ],
|
|
5
|
-
// "collectCoverageFrom": [
|
|
6
|
-
// "src/**/*.{js,jsx,ts,tsx}",
|
|
7
|
-
// "!src/**/*.d.ts"
|
|
8
|
-
// ],
|
|
9
|
-
setupFiles: [require.resolve('react-app-polyfill/jsdom')],
|
|
10
|
-
setupFilesAfterEnv: [require.resolve('./setupTests.js')],
|
|
11
|
-
// "testMatch": [
|
|
12
|
-
// "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
|
|
13
|
-
// "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
|
|
14
|
-
// ],
|
|
15
|
-
testEnvironment: require.resolve('jest-environment-jsdom'),
|
|
16
|
-
transform: {
|
|
17
|
-
'^.+\\.(js|jsx|ts|tsx)$': require.resolve('./transformer'),
|
|
18
|
-
'^.+\\.css$': require.resolve('./css-transform.js'),
|
|
19
|
-
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': require.resolve('./file-transform.js'),
|
|
20
|
-
// '^(?!.*\\.(svg|png|jpg|jpeg|gif|webp|woff|ttf|woff2)$)': require.resolve('./file-transform.js'),
|
|
21
|
-
},
|
|
22
|
-
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$', '^.+\\.module\\.(css|sass|scss)$'],
|
|
23
|
-
modulePaths: [],
|
|
24
|
-
moduleNameMapper: {
|
|
25
|
-
'^react-native$': require.resolve('react-native-web'),
|
|
26
|
-
'^.+\\.module\\.(css|sass|scss)$': require.resolve('identity-obj-proxy'),
|
|
27
|
-
},
|
|
28
|
-
moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'],
|
|
29
|
-
// watchPlugins: [require.resolve('jest-watch-typeahead/filename'), require.resolve('jest-watch-typeahead/testname')],
|
|
30
|
-
};
|
package/jest/setupTests.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// add babel-polyfill.
|
|
2
|
-
// require('babel-polyfill');
|
|
3
|
-
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
4
|
-
// allows you to do things like:
|
|
5
|
-
// expect(element).toHaveTextContent(/react/i)
|
|
6
|
-
// learn more: https://github.com/testing-library/jest-dom
|
|
7
|
-
require('@testing-library/jest-dom/extend-expect');
|
package/jest/transformer.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/* eslint-disable global-require */
|
|
2
|
-
const { transform } = require('@babel/core');
|
|
3
|
-
|
|
4
|
-
const presets = [
|
|
5
|
-
require('@babel/preset-react'),
|
|
6
|
-
require('@babel/preset-typescript'),
|
|
7
|
-
require('babel-preset-jest'),
|
|
8
|
-
[
|
|
9
|
-
require('@babel/preset-env'),
|
|
10
|
-
{
|
|
11
|
-
targets: {
|
|
12
|
-
node: 12,
|
|
13
|
-
},
|
|
14
|
-
useBuiltIns: 'usage',
|
|
15
|
-
corejs: 3,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
];
|
|
19
|
-
const plugins = [
|
|
20
|
-
[require('@babel/plugin-transform-modules-commonjs')],
|
|
21
|
-
[require('babel-plugin-transform-typescript-metadata')],
|
|
22
|
-
[require('@babel/plugin-proposal-decorators'), { legacy: true }],
|
|
23
|
-
[require('@babel/plugin-transform-runtime')],
|
|
24
|
-
[require('@babel/plugin-proposal-object-rest-spread')],
|
|
25
|
-
[require('@babel/plugin-proposal-class-properties')],
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
module.exports = {
|
|
29
|
-
process(src, filename) {
|
|
30
|
-
const result = transform(src, {
|
|
31
|
-
sourceMap: 'inline',
|
|
32
|
-
filename,
|
|
33
|
-
presets,
|
|
34
|
-
plugins,
|
|
35
|
-
babelrc: false,
|
|
36
|
-
configFile: false,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return result ? result.code : src;
|
|
40
|
-
},
|
|
41
|
-
};
|
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