@modern-js/utils 1.15.0 → 1.16.0-alpha.underfin.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.
package/dist/chainId.js CHANGED
@@ -12,6 +12,8 @@ exports.CHAIN_ID = {
12
12
  FONT: 'font',
13
13
  /** Rule for images */
14
14
  IMAGE: 'image',
15
+ /** Rule for media */
16
+ MEDIA: 'media',
15
17
  /** Rule for js */
16
18
  JS: 'js',
17
19
  /** Rule for ts */
@@ -22,6 +24,14 @@ exports.CHAIN_ID = {
22
24
  LESS: 'less',
23
25
  /** Rule for sass */
24
26
  SASS: 'sass',
27
+ /** Rule for svg */
28
+ SVG: 'svg',
29
+ /** Rule for pug */
30
+ PUG: 'pug',
31
+ /** Rule for toml */
32
+ TOML: 'toml',
33
+ /** Rule for yaml */
34
+ YAML: 'yaml',
25
35
  },
26
36
  /** Predefined rule groups */
27
37
  ONE_OF: {
@@ -40,6 +50,7 @@ exports.CHAIN_ID = {
40
50
  SASS_MODULES: 'sass-modules',
41
51
  SVG: 'svg',
42
52
  SVG_URL: 'svg-url',
53
+ SVG_ASSET: 'svg-asset',
43
54
  SVG_INLINE: 'svg-inline',
44
55
  ASSETS: 'assets',
45
56
  ASSETS_URL: 'assets-url',
@@ -57,6 +68,8 @@ exports.CHAIN_ID = {
57
68
  LESS: 'less',
58
69
  /** url-loader */
59
70
  URL: 'url',
71
+ /** pug-loader */
72
+ PUG: 'pug',
60
73
  /** file-loader */
61
74
  FILE: 'file',
62
75
  /** @svgr/webpack */
@@ -69,6 +82,8 @@ exports.CHAIN_ID = {
69
82
  HTML: 'html',
70
83
  /** babel-loader */
71
84
  BABEL: 'babel',
85
+ /** esbuild-loader */
86
+ ESBUILD: 'esbuild',
72
87
  /** style-loader */
73
88
  STYLE: 'style-loader',
74
89
  /** postcss-loader */
@@ -110,12 +125,16 @@ exports.CHAIN_ID = {
110
125
  BUNDLE_ANALYZER: 'bundle-analyze',
111
126
  /** BottomTemplatePlugin */
112
127
  BOTTOM_TEMPLATE: 'bottom-template',
128
+ /** HtmlCrossOriginPlugin */
129
+ HTML_CROSS_ORIGIN: 'html-cross-origin',
113
130
  /** MiniCssExtractPlugin */
114
131
  MINI_CSS_EXTRACT: 'mini-css-extract',
115
132
  /** ReactFastRefreshPlugin */
116
133
  REACT_FAST_REFRESH: 'react-fast-refresh',
117
134
  /** ProvidePlugin for node polyfill */
118
135
  NODE_POLYFILL_PROVIDE: 'node-polyfill-provide',
136
+ /** ModuleDependencyErrorPlugin */
137
+ MODULE_DEPENDENCY_ERROR: 'module-dependency-error',
119
138
  },
120
139
  /** Predefined minimizers */
121
140
  MINIMIZER: {
package/dist/constants.js CHANGED
@@ -98,20 +98,10 @@ exports.INTERNAL_PLUGINS = {
98
98
  cli: '@modern-js/plugin-garfish/cli',
99
99
  },
100
100
  '@modern-js/plugin-tailwindcss': { cli: '@modern-js/plugin-tailwindcss/cli' },
101
- '@modern-js/plugin-lambda-fc': { cli: '@modern-js/plugin-lambda-fc/cli' },
102
- '@modern-js/plugin-lambda-scf': { cli: '@modern-js/plugin-lambda-scf/cli' },
103
- '@modern-js/plugin-cdn-oss': { cli: '@modern-js/plugin-cdn-oss/cli' },
104
- '@modern-js/plugin-cdn-cos': { cli: '@modern-js/plugin-cdn-cos/cli' },
105
- '@modern-js/plugin-static-hosting': {
106
- cli: '@modern-js/plugin-static-hosting/cli',
107
- },
108
101
  '@modern-js/plugin-polyfill': {
109
102
  cli: '@modern-js/plugin-polyfill/cli',
110
103
  server: '@modern-js/plugin-polyfill',
111
104
  },
112
- '@modern-js/plugin-multiprocess': {
113
- cli: '@modern-js/plugin-multiprocess/cli',
114
- },
115
105
  // TODO: Maybe can remove it
116
106
  '@modern-js/plugin-nocode': { cli: '@modern-js/plugin-nocode/cli' },
117
107
  };
package/dist/format.d.ts CHANGED
@@ -6,11 +6,8 @@
6
6
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
7
  */
8
8
  import type { StatsCompilation } from 'webpack';
9
- import type { ProxyDetail, BffProxyOptions } from '@modern-js/types';
10
9
  declare function formatWebpackMessages(json: StatsCompilation): {
11
10
  errors: string[];
12
11
  warnings: string[];
13
12
  };
14
13
  export { formatWebpackMessages };
15
- declare function formatProxyOptions(proxyOptions: BffProxyOptions): ProxyDetail[];
16
- export { formatProxyOptions };
package/dist/format.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.formatProxyOptions = exports.formatWebpackMessages = void 0;
10
+ exports.formatWebpackMessages = void 0;
11
11
  const friendlySyntaxErrorLabel = 'SyntaxError:';
12
12
  function isLikelyASyntaxError(message) {
13
13
  return message.includes(friendlySyntaxErrorLabel);
@@ -86,28 +86,3 @@ function formatWebpackMessages(json) {
86
86
  return result;
87
87
  }
88
88
  exports.formatWebpackMessages = formatWebpackMessages;
89
- function formatProxyOptions(proxyOptions) {
90
- const formattedProxy = [];
91
- if (!Array.isArray(proxyOptions)) {
92
- if ('target' in proxyOptions) {
93
- formattedProxy.push(proxyOptions);
94
- }
95
- else {
96
- Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
97
- const option = proxyOptions[source];
98
- total.push({
99
- context: source,
100
- changeOrigin: true,
101
- logLevel: 'warn',
102
- ...(typeof option === 'string' ? { target: option } : option),
103
- });
104
- return total;
105
- }, []));
106
- }
107
- }
108
- else {
109
- formattedProxy.push(...proxyOptions);
110
- }
111
- return formattedProxy;
112
- }
113
- exports.formatProxyOptions = formatProxyOptions;
package/dist/index.d.ts CHANGED
@@ -34,3 +34,4 @@ export * from './ssr';
34
34
  export * from './tryResolve';
35
35
  export * from './analyzeProject';
36
36
  export * from './chainId';
37
+ export * from './reactVersion';
package/dist/index.js CHANGED
@@ -50,3 +50,4 @@ __exportStar(require("./ssr"), exports);
50
50
  __exportStar(require("./tryResolve"), exports);
51
51
  __exportStar(require("./analyzeProject"), exports);
52
52
  __exportStar(require("./chainId"), exports);
53
+ __exportStar(require("./reactVersion"), exports);
@@ -5,5 +5,9 @@ interface EntryPoint {
5
5
  }
6
6
  export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
7
7
  export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
8
+ export declare const getAddressUrls: (protocol: string | undefined, port: number) => {
9
+ type: string;
10
+ url: string;
11
+ }[];
8
12
  export declare const prettyInstructions: (appContext: any, config: any) => string;
9
13
  export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.prettyInstructions = exports.getIpv4Interfaces = exports.isSingleEntry = void 0;
6
+ exports.prettyInstructions = exports.getAddressUrls = exports.getIpv4Interfaces = exports.isSingleEntry = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const compiled_1 = require("./compiled");
9
9
  const is_1 = require("./is");
@@ -39,9 +39,10 @@ const getAddressUrls = (protocol = 'http', port) => {
39
39
  return memo;
40
40
  }, []);
41
41
  };
42
+ exports.getAddressUrls = getAddressUrls;
42
43
  const prettyInstructions = (appContext, config) => {
43
44
  const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
44
- const urls = getAddressUrls(config.dev.https && (0, is_1.isDev)() ? 'https' : 'http', port);
45
+ const urls = (0, exports.getAddressUrls)(config.dev.https && (0, is_1.isDev)() ? 'https' : 'http', port);
45
46
  const routes = !apiOnly
46
47
  ? serverRoutes.filter(route => route.entryName)
47
48
  : serverRoutes;
@@ -0,0 +1 @@
1
+ export declare const isReact18: (cwd: string) => boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isReact18 = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const compiled_1 = require("./compiled");
9
+ const isReact18 = (cwd) => {
10
+ const pkgPath = path_1.default.join(cwd, 'package.json');
11
+ if (!compiled_1.fs.existsSync(pkgPath)) {
12
+ return false;
13
+ }
14
+ const pkgInfo = JSON.parse(compiled_1.fs.readFileSync(pkgPath, 'utf8'));
15
+ const deps = {
16
+ ...pkgInfo.devDependencies,
17
+ ...pkgInfo.dependencies,
18
+ };
19
+ if (typeof deps.react !== 'string') {
20
+ return false;
21
+ }
22
+ return compiled_1.semver.satisfies(compiled_1.semver.minVersion(deps.react), '>=18.0.0');
23
+ };
24
+ exports.isReact18 = isReact18;
@@ -1,4 +1,4 @@
1
- export declare const createRuntimeExportsUtils: (pwd: any, namespace: string, ts?: any) => {
1
+ export declare const createRuntimeExportsUtils: (pwd?: any, namespace?: any) => {
2
2
  addExport: (statement: string) => void;
3
3
  getPath: () => string;
4
4
  };
@@ -20,9 +20,8 @@ const memo = (fn) => {
20
20
  return res;
21
21
  };
22
22
  };
23
- exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
24
- const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
25
- const entryExportTsFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.d.ts` : 'index.d.ts'}`);
23
+ exports.createRuntimeExportsUtils = memo((pwd = '', namespace = 'index') => {
24
+ const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace}.js`);
26
25
  // const ensure = () => {
27
26
  // if (!fs.existsSync(entryExportFile)) {
28
27
  // fs.outputFileSync(entryExportFile, '');
@@ -34,11 +33,8 @@ exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
34
33
  statement = (0, path_2.normalizeOutputPath)(statement);
35
34
  try {
36
35
  compiled_1.fs.ensureFileSync(entryExportFile);
37
- compiled_1.fs.ensureFileSync(entryExportTsFile);
38
36
  if (!compiled_1.fs.readFileSync(entryExportFile, 'utf8').includes(statement)) {
39
37
  compiled_1.fs.appendFileSync(entryExportFile, `${statement}\n`);
40
- ts &&
41
- compiled_1.fs.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
42
38
  }
43
39
  }
44
40
  catch {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.15.0",
14
+ "version": "1.16.0-alpha.underfin.001",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -40,6 +40,7 @@
40
40
  "./webpack-chain": "./compiled/webpack-chain/index.js",
41
41
  "./tsconfig-paths": "./compiled/tsconfig-paths/index.js",
42
42
  "./better-ajv-errors": "./compiled/better-ajv-errors/index.js",
43
+ "./webpack-dev-middleware": "./compiled/webpack-dev-middleware/index.js",
43
44
  "./chain-id": "./dist/chainId.js"
44
45
  },
45
46
  "publishConfig": {
@@ -111,6 +112,9 @@
111
112
  "better-ajv-errors": [
112
113
  "./compiled/better-ajv-errors/index.d.ts"
113
114
  ],
115
+ "webpack-dev-middleware": [
116
+ "./compiled/webpack-dev-middleware/types/index.d.ts"
117
+ ],
114
118
  "chain-id": [
115
119
  "./dist/chainId.d.ts"
116
120
  ]
@@ -121,7 +125,7 @@
121
125
  "lodash": "^4.17.21"
122
126
  },
123
127
  "devDependencies": {
124
- "@modern-js/types": "1.15.0",
128
+ "@modern-js/types": "1.16.0",
125
129
  "@scripts/build": "1.15.0",
126
130
  "@scripts/jest-config": "1.15.0",
127
131
  "@types/jest": "^27",