@xfe-repo/web-app 1.6.3 → 2.0.0-beta.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 (48) hide show
  1. package/README.md +60 -1
  2. package/client.d.ts +1 -0
  3. package/deploy/.drone.yml +11 -4
  4. package/deploy/Dockerfile +14 -6
  5. package/deploy/helm/templates/deployment.yaml +5 -18
  6. package/deploy/helm/templates/svc.yaml +1 -1
  7. package/dist/cli.js +275 -413
  8. package/dist/cli.mjs +273 -267
  9. package/dist/config.d.mts +20 -6
  10. package/dist/config.d.ts +20 -6
  11. package/dist/config.js +83 -297
  12. package/dist/config.mjs +69 -2
  13. package/dist/framework.d.mts +10 -0
  14. package/dist/framework.d.ts +10 -0
  15. package/dist/framework.js +174 -0
  16. package/dist/framework.mjs +137 -0
  17. package/dist/react-router-config.d.mts +11 -0
  18. package/dist/react-router-config.d.ts +11 -0
  19. package/dist/react-router-config.js +66 -0
  20. package/dist/react-router-config.mjs +35 -0
  21. package/dist/root.d.mts +17 -0
  22. package/dist/root.d.ts +17 -0
  23. package/dist/root.js +61 -0
  24. package/dist/root.mjs +34 -0
  25. package/dist/serve.d.mts +10 -0
  26. package/dist/serve.d.ts +10 -0
  27. package/dist/serve.js +71 -0
  28. package/dist/serve.mjs +36 -0
  29. package/dist/vite.d.mts +9 -0
  30. package/dist/vite.d.ts +9 -0
  31. package/dist/vite.js +135 -0
  32. package/dist/vite.mjs +100 -0
  33. package/package.json +22 -71
  34. package/tsconfig.json +4 -1
  35. package/config/env.js +0 -104
  36. package/config/getHttpsConfig.js +0 -66
  37. package/config/jest/babelTransform.js +0 -29
  38. package/config/jest/cssTransform.js +0 -14
  39. package/config/jest/fileTransform.js +0 -40
  40. package/config/modules.js +0 -133
  41. package/config/paths.js +0 -65
  42. package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
  43. package/config/webpack/webpack.config.js +0 -737
  44. package/config/webpack/webpackDevServer.config.js +0 -122
  45. package/deploy/nginx.conf +0 -62
  46. package/dist/chunk-75BJNL7E.mjs +0 -239
  47. package/scripts/build.js +0 -217
  48. package/scripts/dev.js +0 -162
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- const babelJest = require('babel-jest').default;
4
-
5
- const hasJsxRuntime = (() => {
6
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
7
- return false;
8
- }
9
-
10
- try {
11
- require.resolve('react/jsx-runtime');
12
- return true;
13
- } catch (e) {
14
- return false;
15
- }
16
- })();
17
-
18
- module.exports = babelJest.createTransformer({
19
- presets: [
20
- [
21
- require.resolve('babel-preset-react-app'),
22
- {
23
- runtime: hasJsxRuntime ? 'automatic' : 'classic',
24
- },
25
- ],
26
- ],
27
- babelrc: false,
28
- configFile: false,
29
- });
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- // This is a custom Jest transformer turning style imports into empty objects.
4
- // http://facebook.github.io/jest/docs/en/webpack.html
5
-
6
- module.exports = {
7
- process() {
8
- return 'module.exports = {};';
9
- },
10
- getCacheKey() {
11
- // The output is always the same.
12
- return 'cssTransform';
13
- },
14
- };
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const camelcase = require('camelcase');
5
-
6
- // This is a custom Jest transformer turning file imports into filenames.
7
- // http://facebook.github.io/jest/docs/en/webpack.html
8
-
9
- module.exports = {
10
- process(src, filename) {
11
- const assetFilename = JSON.stringify(path.basename(filename));
12
-
13
- if (filename.match(/\.svg$/)) {
14
- // Based on how SVGR generates a component name:
15
- // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16
- const pascalCaseFilename = camelcase(path.parse(filename).name, {
17
- pascalCase: true,
18
- });
19
- const componentName = `Svg${pascalCaseFilename}`;
20
- return `const React = require('react');
21
- module.exports = {
22
- __esModule: true,
23
- default: ${assetFilename},
24
- ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25
- return {
26
- $$typeof: Symbol.for('react.element'),
27
- type: 'svg',
28
- ref: ref,
29
- key: null,
30
- props: Object.assign({}, props, {
31
- children: ${assetFilename}
32
- })
33
- };
34
- }),
35
- };`;
36
- }
37
-
38
- return `module.exports = ${assetFilename};`;
39
- },
40
- };
package/config/modules.js DELETED
@@ -1,133 +0,0 @@
1
- 'use strict'
2
-
3
- const fs = require('fs')
4
- const path = require('path')
5
- const paths = require('./paths')
6
- const chalk = require('react-dev-utils/chalk')
7
- const resolve = require('resolve')
8
-
9
- /**
10
- * Get additional module paths based on the baseUrl of a compilerOptions object.
11
- *
12
- * @param {Object} options
13
- */
14
- function getAdditionalModulePaths(options = {}) {
15
- const baseUrl = options.baseUrl
16
-
17
- if (!baseUrl) {
18
- return ''
19
- }
20
-
21
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl)
22
-
23
- // We don't need to do anything if `baseUrl` is set to `node_modules`. This is
24
- // the default behavior.
25
- if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
26
- return null
27
- }
28
-
29
- // Allow the user set the `baseUrl` to `appSrc`.
30
- if (path.relative(paths.appSrc, baseUrlResolved) === '') {
31
- return [paths.appSrc]
32
- }
33
-
34
- // If the path is equal to the root directory we ignore it here.
35
- // We don't want to allow importing from the root directly as source files are
36
- // not transpiled outside of `src`. We do allow importing them with the
37
- // absolute path (e.g. `src/Components/Button.js`) but we set that up with
38
- // an alias.
39
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
40
- return null
41
- }
42
-
43
- // Otherwise, throw an error.
44
- throw new Error(
45
- chalk.red.bold(
46
- "Your project's `baseUrl` can only be set to `src` or `node_modules`." +
47
- ' Create React App does not support other values at this time.'
48
- )
49
- )
50
- }
51
-
52
- /**
53
- * Get webpack aliases based on the baseUrl of a compilerOptions object.
54
- *
55
- * @param {*} options
56
- */
57
- function getWebpackAliases(options = {}) {
58
- const baseUrl = options.baseUrl
59
-
60
- const customAliases = {
61
- '@': paths.appSrc,
62
- '@common/services': '@xfe-repo/web-service',
63
- }
64
-
65
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl)
66
-
67
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
68
- customAliases.src = paths.appSrc
69
- }
70
-
71
- return { ...customAliases }
72
- }
73
-
74
- /**
75
- * Get jest aliases based on the baseUrl of a compilerOptions object.
76
- *
77
- * @param {*} options
78
- */
79
- function getJestAliases(options = {}) {
80
- const baseUrl = options.baseUrl
81
-
82
- if (!baseUrl) {
83
- return {}
84
- }
85
-
86
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl)
87
-
88
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
89
- return {
90
- '^src/(.*)$': '<rootDir>/src/$1',
91
- }
92
- }
93
- }
94
-
95
- function getModules() {
96
- // Check if TypeScript is setup
97
- const hasTsConfig = fs.existsSync(paths.appTsConfig)
98
- const hasJsConfig = fs.existsSync(paths.appJsConfig)
99
-
100
- if (hasTsConfig && hasJsConfig) {
101
- throw new Error('You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.')
102
- }
103
-
104
- let config
105
-
106
- // If there's a tsconfig.json we assume it's a
107
- // TypeScript project and set up the config
108
- // based on tsconfig.json
109
- if (hasTsConfig) {
110
- const ts = require(resolve.sync('typescript', {
111
- basedir: paths.appNodeModules,
112
- }))
113
- config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config
114
- // Otherwise we'll check if there is jsconfig.json
115
- // for non TS projects.
116
- } else if (hasJsConfig) {
117
- config = require(paths.appJsConfig)
118
- }
119
-
120
- config = config || {}
121
- const options = config.compilerOptions || {}
122
-
123
- const additionalModulePaths = getAdditionalModulePaths(options)
124
-
125
- return {
126
- additionalModulePaths: additionalModulePaths,
127
- webpackAliases: getWebpackAliases(options),
128
- jestAliases: getJestAliases(options),
129
- hasTsConfig,
130
- }
131
- }
132
-
133
- module.exports = getModules()
package/config/paths.js DELETED
@@ -1,65 +0,0 @@
1
- 'use strict'
2
-
3
- const path = require('path')
4
- const fs = require('fs')
5
- const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath')
6
-
7
- // Make sure any symlinks in the project folder are resolved:
8
- // https://github.com/facebook/create-react-app/issues/637
9
- const appDirectory = fs.realpathSync(process.cwd())
10
- const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath)
11
-
12
- // We use `PUBLIC_URL` environment variable or "homepage" field to infer
13
- // "public path" at which the app is served.
14
- // webpack needs to know it to put the right <script> hrefs into HTML even in
15
- // single-page apps that may serve index.html for nested URLs like /todos/42.
16
- // We can't use a relative path in HTML because we don't want to load something
17
- // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
18
- const publicUrlOrPath = getPublicUrlOrPath(
19
- process.env.NODE_ENV === 'development',
20
- require(resolveApp('package.json')).homepage,
21
- process.env.PUBLIC_URL
22
- )
23
-
24
- const moduleFileExtensions = ['web.mjs', 'mjs', 'web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx']
25
-
26
- // Resolve file paths in the same order as webpack
27
- const resolveModule = (resolveFn, filePath) => {
28
- const extension = moduleFileExtensions.find((extension) => fs.existsSync(resolveFn(`${filePath}.${extension}`)))
29
-
30
- if (extension) {
31
- return resolveFn(`${filePath}.${extension}`)
32
- }
33
-
34
- return resolveFn(`${filePath}.js`)
35
- }
36
-
37
- // config after eject: we're in ./config/
38
- module.exports = {
39
- dotenv: resolveApp('.env'),
40
- appPath: resolveApp('.'),
41
- // modify 修改输出目录
42
- appBuild: resolveApp('build/client'),
43
- // modify 修改输出目录
44
- appBuildServer: resolveApp('build/server'),
45
- // modify 修改public目录
46
- appPublic: resolveApp('src/assets/public'),
47
- appHtml: resolveApp('src/assets/public/index.html'),
48
- appIndexJs: resolveModule(resolveApp, 'src/index'),
49
- // modify 新增ssr入口文件
50
- appSSRJs: resolveApp('src/ssr.tsx'),
51
- appPackageJson: resolveApp('package.json'),
52
- appSrc: resolveApp('src'),
53
- appTsConfig: resolveApp('tsconfig.json'),
54
- appJsConfig: resolveApp('jsconfig.json'),
55
- yarnLockFile: resolveApp('yarn.lock'),
56
- testsSetup: resolveModule(resolveApp, 'src/setupTests'),
57
- proxySetup: resolveApp('src/setupProxy.js'),
58
- appNodeModules: resolveApp('node_modules'),
59
- appWebpackCache: resolveApp('node_modules/.cache'),
60
- appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
61
- swSrc: resolveModule(resolveApp, 'src/service-worker'),
62
- publicUrlOrPath,
63
- }
64
-
65
- module.exports.moduleFileExtensions = moduleFileExtensions
@@ -1,9 +0,0 @@
1
- 'use strict';
2
- const { createHash } = require('crypto');
3
-
4
- module.exports = env => {
5
- const hash = createHash('md5');
6
- hash.update(JSON.stringify(env));
7
-
8
- return hash.digest('hex');
9
- };