@modern-js/core 1.11.0-beta.1 → 1.11.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @modern-js/core
2
2
 
3
+ ## 1.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8d508c6ed: feat(devServer): support disable hmr or live reload
8
+ - 0eff2473c: ignore devServer config fn merge
9
+ - f25d6a62e: fix: change bffConfig type define to interface
10
+ - a18926bbd: fix(app-tools): dev --config not working
11
+ - 8f7c0f898: feat(app-tools): support specify config file in build and deploy command
12
+ - Updated dependencies [a1198d509]
13
+ - Updated dependencies [a18926bbd]
14
+ - @modern-js/load-config@1.3.4
15
+ - @modern-js/plugin@1.3.6
16
+
17
+ ## 1.11.1
18
+
19
+ ### Patch Changes
20
+
21
+ - f730081c: feat: modify `RuntimeConfig` type to make it extensible
22
+ - d1ab1f05: fix(core): should not register the `core` command
23
+ - 2ec8181a: fix(core): modern --version get incorrect value
24
+ - 6451a098: fix: cyclic dependencies of @modern-js/core and @moden-js/webpack
25
+ - 7fcfd6cc: fix(core): fix tools.postcss typing
26
+ - Updated dependencies [6451a098]
27
+ - Updated dependencies [d5a2cfd8]
28
+ - Updated dependencies [437367c6]
29
+ - @modern-js/utils@1.7.6
30
+
3
31
  ## 1.11.0
4
32
 
5
33
  ### Minor Changes
package/dist/bin.js CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ /* eslint-disable-next-line eslint-comments/disable-enable-pair */
4
+ /* eslint-disable import/first */
3
5
  Object.defineProperty(exports, "__esModule", { value: true });
4
6
  require('../compiled/v8-compile-cache');
5
- // eslint-disable-next-line import/first
7
+ const utils_1 = require("@modern-js/utils");
6
8
  const _1 = require(".");
9
+ const command = process.argv[2];
7
10
  if (!process.env.NODE_ENV) {
8
- const command = process.argv[2];
9
11
  if (['build', 'start', 'deploy'].includes(command)) {
10
12
  process.env.NODE_ENV = 'production';
11
13
  }
@@ -17,4 +19,11 @@ if (!process.env.NODE_ENV) {
17
19
  }
18
20
  }
19
21
  const { version } = require('../package.json');
20
- _1.cli.run(process.argv.slice(2), { version });
22
+ const cliParams = (0, utils_1.minimist)(process.argv.slice(2));
23
+ const runOptions = {
24
+ version,
25
+ };
26
+ if (['dev', 'build', 'deploy'].includes(command) && cliParams.config) {
27
+ runOptions.configFile = cliParams.config;
28
+ }
29
+ _1.cli.run(process.argv.slice(2), runOptions);
@@ -11,7 +11,10 @@ const utils_1 = require("@modern-js/utils");
11
11
  */
12
12
  const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source, key) => {
13
13
  // Do not use the following merge logic for source.designSystem and tools.tailwind(css)
14
- if (key === 'designSystem' || key === 'tailwind' || key === 'tailwindcss') {
14
+ if (key === 'designSystem' ||
15
+ key === 'tailwind' ||
16
+ key === 'tailwindcss' ||
17
+ key === 'devServer') {
15
18
  return (0, lodash_1.mergeWith)({}, target !== null && target !== void 0 ? target : {}, source !== null && source !== void 0 ? source : {});
16
19
  }
17
20
  if (Array.isArray(target)) {
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import type { IncomingMessage, ServerResponse } from 'http';
3
3
  import type { NextFunction, BffProxyOptions } from '@modern-js/types';
4
- import type { MetaOptions } from '@modern-js/utils';
4
+ import type { MetaOptions, ChainIdentifier } from '@modern-js/utils';
5
5
  import type { TransformOptions } from '@babel/core';
6
6
  import type webpack from 'webpack';
7
- import type { Configuration as WebpackConfiguration } from 'webpack';
8
- import type { ChainIdentifier, WebpackChain } from '@modern-js/webpack';
7
+ import type { RuleSetRule, Configuration as WebpackConfiguration } from 'webpack';
8
+ import type WebpackChain from '@modern-js/utils/webpack-chain';
9
9
  import type autoprefixer from 'autoprefixer';
10
10
  import type { BasePluginOptions, TerserOptions as RawTerserOptions } from 'terser-webpack-plugin';
11
11
  import type { PluginConfig } from '../../loadPlugins';
@@ -14,7 +14,8 @@ import type { SassConfig, SassLoaderOptions } from './sass';
14
14
  import type { LessConfig, LessLoaderOptions } from './less';
15
15
  import type { UnbundleConfig } from './unbundle';
16
16
  import type { SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions } from './ssg';
17
- import { ElectronConfig } from './electron';
17
+ import type { ElectronConfig } from './electron';
18
+ import type { PostCSSLoaderOptions } from './postcss';
18
19
  declare type AutoprefixerOptions = autoprefixer.Options;
19
20
  declare type TerserOptions = BasePluginOptions & RawTerserOptions;
20
21
  export type { TestConfig, JestConfig, UnbundleConfig, SassConfig, SassLoaderOptions, LessConfig, LessLoaderOptions, SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions, TransformOptions, AutoprefixerOptions, TerserOptions, };
@@ -141,21 +142,27 @@ export interface DeployConfig {
141
142
  declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>, utils?: any) => Record<string, unknown> | void);
142
143
  export declare type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
143
144
  export declare type DevServerConfig = {
145
+ hot?: boolean;
146
+ liveReload?: boolean;
144
147
  proxy?: BffProxyOptions;
145
148
  headers?: Record<string, string>;
146
149
  before?: RequestHandler[];
147
150
  after?: RequestHandler[];
148
151
  [propsName: string]: any;
149
152
  };
153
+ export declare type PostCSSConfig = PostCSSLoaderOptions | ((options: PostCSSLoaderOptions) => PostCSSLoaderOptions | void);
150
154
  export declare type WebpackConfig = WebpackConfiguration | ((config: WebpackConfiguration, utils: {
151
155
  env: string;
152
156
  name: string;
153
157
  webpack: typeof webpack;
158
+ addRules: (rules: RuleSetRule[]) => void;
159
+ prependPlugins: (plugins: WebpackConfiguration['plugins']) => void;
160
+ appendPlugins: (plugins: WebpackConfiguration['plugins']) => void;
161
+ removePlugin: (pluginName: string) => void;
154
162
  /**
155
163
  * @deprecated please use `tools.webpackChain` instead.
156
164
  */
157
165
  chain: WebpackChain;
158
- [key: string]: any;
159
166
  }) => WebpackConfiguration | void);
160
167
  export declare type WebpackChainConfig = (chain: WebpackChain, utils: {
161
168
  env: string;
@@ -171,7 +178,7 @@ export interface ToolsConfig {
171
178
  webpackChain?: WebpackChainConfig;
172
179
  babel?: BabelConfig;
173
180
  autoprefixer?: AutoprefixerConfig;
174
- postcss?: ConfigFunction;
181
+ postcss?: PostCSSConfig;
175
182
  styledComponents?: ConfigFunction;
176
183
  lodash?: ConfigFunction;
177
184
  devServer?: DevServerConfig;
@@ -204,16 +211,18 @@ export interface ToolsConfig {
204
211
  */
205
212
  less?: LessConfig;
206
213
  }
207
- export declare type RuntimeConfig = Record<string, any>;
214
+ export interface RuntimeConfig {
215
+ [name: string]: any;
216
+ }
208
217
  export interface RuntimeByEntriesConfig {
209
218
  [name: string]: RuntimeConfig;
210
219
  }
211
- export declare type BffConfig = Partial<{
212
- prefix: string;
213
- requestCreator: string;
214
- fetcher: string;
215
- proxy: Record<string, any>;
216
- }>;
220
+ export interface BffConfig {
221
+ prefix?: string;
222
+ requestCreator?: string;
223
+ fetcher?: string;
224
+ proxy?: Record<string, any>;
225
+ }
217
226
  export interface UserConfig {
218
227
  source?: SourceConfig;
219
228
  output?: OutputConfig;
@@ -0,0 +1,28 @@
1
+ import type { Syntax, Parser, Stringifier, AcceptedPlugin, SourceMapOptions } from 'postcss';
2
+ export declare type PostCSSOptions = {
3
+ to?: string;
4
+ from?: string;
5
+ map?: boolean | SourceMapOptions;
6
+ syntax?: Syntax;
7
+ parser?: string | object | (() => Parser);
8
+ plugins?: AcceptedPlugin[];
9
+ stringifier?: Stringifier | Syntax;
10
+ };
11
+ export declare type PostCSSLoaderOptions = {
12
+ /**
13
+ * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
14
+ */
15
+ execute?: boolean;
16
+ /**
17
+ * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.
18
+ */
19
+ sourceMap?: boolean;
20
+ /**
21
+ * The special implementation option determines which implementation of PostCSS to use.
22
+ */
23
+ implementation?: unknown;
24
+ /**
25
+ * Allows to set PostCSS options and plugins.
26
+ */
27
+ postcssOptions?: PostCSSOptions;
28
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,7 +31,6 @@ function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
31
31
  .filter(name => {
32
32
  const config = allPlugins[name];
33
33
  if (config.forced === true) {
34
- // 参考 packages/cli/core/src/bin.ts 文件
35
34
  return true;
36
35
  }
37
36
  return (0, utils_1.isDepExists)(appDirectory, name);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.11.0-beta.1",
14
+ "version": "1.11.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -38,16 +38,14 @@
38
38
  ]
39
39
  }
40
40
  },
41
- "bin": "./dist/bin.js",
42
41
  "dependencies": {
43
- "@modern-js/load-config": "^1.3.2",
44
- "@modern-js/plugin": "^1.3.4",
45
- "@modern-js/utils": "^1.7.4"
42
+ "@modern-js/load-config": "^1.3.4",
43
+ "@modern-js/plugin": "^1.3.6",
44
+ "@modern-js/utils": "^1.7.6"
46
45
  },
47
46
  "devDependencies": {
48
47
  "@jest/types": "^27.0.6",
49
- "@modern-js/types": "1.5.3",
50
- "@modern-js/webpack": "1.8.0",
48
+ "@modern-js/types": "1.5.4",
51
49
  "@scripts/build": "0.0.0",
52
50
  "@scripts/jest-config": "0.0.0",
53
51
  "@types/babel__code-frame": "^7.0.3",
@@ -60,6 +58,7 @@
60
58
  "autoprefixer": "^10.3.1",
61
59
  "btsm": "2.2.2",
62
60
  "jest": "^27",
61
+ "postcss": "^8",
63
62
  "sass": "^1.45.0",
64
63
  "electron-builder": "22.7.0",
65
64
  "terser-webpack-plugin": "^5.1.4",