@modern-js/app-tools 2.39.1 → 2.39.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.
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var inits_exports = {};
30
30
  __export(inits_exports, {
31
+ createBuilderModuleScope: () => createBuilderModuleScope,
31
32
  initHtmlConfig: () => initHtmlConfig,
32
33
  initSourceConfig: () => initSourceConfig
33
34
  });
@@ -62,57 +63,52 @@ function initSourceConfig(config, appContext, bundler) {
62
63
  if (bundler === "webpack") {
63
64
  config.source.moduleScopes = createBuilderModuleScope(config);
64
65
  }
65
- function createBuilderInclude(config2, appContext2) {
66
- const { include } = config2.source;
67
- const defaultInclude = [
68
- appContext2.internalDirectory
69
- ];
70
- const transformInclude = (include || []).map((include2) => {
71
- if (typeof include2 === "string") {
72
- if ((0, import_path.isAbsolute)(include2)) {
73
- return include2;
74
- }
75
- return new RegExp(include2);
66
+ }
67
+ function createBuilderInclude(config, appContext) {
68
+ const { include } = config.source;
69
+ const defaultInclude = [
70
+ appContext.internalDirectory
71
+ ];
72
+ const transformInclude = (include || []).map((include2) => {
73
+ if (typeof include2 === "string") {
74
+ if ((0, import_path.isAbsolute)(include2)) {
75
+ return include2;
76
76
  }
77
- return include2;
78
- }).concat(defaultInclude);
79
- return transformInclude;
77
+ return new RegExp(include2);
78
+ }
79
+ return include2;
80
+ }).concat(defaultInclude);
81
+ return transformInclude;
82
+ }
83
+ function createBuilderModuleScope(config) {
84
+ const { moduleScopes } = config.source;
85
+ if (moduleScopes) {
86
+ const DEFAULT_SCOPES = [
87
+ "./src",
88
+ "./shared",
89
+ /node_modules/
90
+ ];
91
+ const builderModuleScope = applyScopeOptions(DEFAULT_SCOPES, moduleScopes);
92
+ return builderModuleScope;
93
+ } else {
94
+ return void 0;
80
95
  }
81
- function createBuilderModuleScope(config2) {
82
- const { moduleScopes } = config2.source;
83
- if (moduleScopes) {
84
- let builderModuleScope = [];
85
- const DEFAULT_SCOPES = [
86
- "./src",
87
- "./shared",
88
- /node_modules/
89
- ];
90
- if (Array.isArray(moduleScopes)) {
91
- if (isPrimitiveScope(moduleScopes)) {
92
- builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
93
- } else {
94
- builderModuleScope = [
95
- DEFAULT_SCOPES,
96
- ...moduleScopes
97
- ];
98
- }
99
- } else {
100
- builderModuleScope = [
101
- DEFAULT_SCOPES,
102
- moduleScopes
103
- ];
96
+ function isPrimitiveScope(items) {
97
+ return items.every((item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]");
98
+ }
99
+ function applyScopeOptions(defaults, options) {
100
+ if (Array.isArray(options)) {
101
+ if (isPrimitiveScope(options)) {
102
+ return defaults.concat(options);
104
103
  }
105
- return builderModuleScope;
106
- } else {
107
- return void 0;
108
- }
109
- function isPrimitiveScope(items) {
110
- return items.every((item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]");
104
+ return options.reduce(applyScopeOptions, defaults);
111
105
  }
106
+ return options(defaults) || defaults;
112
107
  }
113
108
  }
114
109
  // Annotate the CommonJS export names for ESM import in node:
115
110
  0 && (module.exports = {
111
+ createBuilderModuleScope,
116
112
  initHtmlConfig,
117
113
  initSourceConfig
118
114
  });
@@ -1,4 +1,3 @@
1
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
1
  import path, { isAbsolute } from "path";
3
2
  import { findExists } from "@modern-js/utils";
4
3
  function initHtmlConfig(config, appContext) {
@@ -29,61 +28,57 @@ function initHtmlConfig(config, appContext) {
29
28
  return config.html;
30
29
  }
31
30
  function initSourceConfig(config, appContext, bundler) {
32
- var createBuilderInclude = function createBuilderInclude2(config2, appContext2) {
33
- var include = config2.source.include;
34
- var defaultInclude = [
35
- appContext2.internalDirectory
36
- ];
37
- var transformInclude = (include || []).map(function(include2) {
38
- if (typeof include2 === "string") {
39
- if (isAbsolute(include2)) {
40
- return include2;
41
- }
42
- return new RegExp(include2);
31
+ config.source.include = createBuilderInclude(config, appContext);
32
+ if (bundler === "webpack") {
33
+ config.source.moduleScopes = createBuilderModuleScope(config);
34
+ }
35
+ }
36
+ function createBuilderInclude(config, appContext) {
37
+ var include = config.source.include;
38
+ var defaultInclude = [
39
+ appContext.internalDirectory
40
+ ];
41
+ var transformInclude = (include || []).map(function(include2) {
42
+ if (typeof include2 === "string") {
43
+ if (isAbsolute(include2)) {
44
+ return include2;
43
45
  }
44
- return include2;
45
- }).concat(defaultInclude);
46
- return transformInclude;
46
+ return new RegExp(include2);
47
+ }
48
+ return include2;
49
+ }).concat(defaultInclude);
50
+ return transformInclude;
51
+ }
52
+ function createBuilderModuleScope(config) {
53
+ var isPrimitiveScope = function isPrimitiveScope2(items) {
54
+ return items.every(function(item) {
55
+ return typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]";
56
+ });
47
57
  };
48
- var createBuilderModuleScope = function createBuilderModuleScope2(config2) {
49
- var moduleScopes = config2.source.moduleScopes;
50
- if (moduleScopes) {
51
- var builderModuleScope = [];
52
- var DEFAULT_SCOPES = [
53
- "./src",
54
- "./shared",
55
- /node_modules/
56
- ];
57
- if (Array.isArray(moduleScopes)) {
58
- if (isPrimitiveScope(moduleScopes)) {
59
- builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
60
- } else {
61
- builderModuleScope = [
62
- DEFAULT_SCOPES
63
- ].concat(_to_consumable_array(moduleScopes));
64
- }
65
- } else {
66
- builderModuleScope = [
67
- DEFAULT_SCOPES,
68
- moduleScopes
69
- ];
58
+ var moduleScopes = config.source.moduleScopes;
59
+ if (moduleScopes) {
60
+ var DEFAULT_SCOPES = [
61
+ "./src",
62
+ "./shared",
63
+ /node_modules/
64
+ ];
65
+ var builderModuleScope = applyScopeOptions(DEFAULT_SCOPES, moduleScopes);
66
+ return builderModuleScope;
67
+ } else {
68
+ return void 0;
69
+ }
70
+ function applyScopeOptions(defaults, options) {
71
+ if (Array.isArray(options)) {
72
+ if (isPrimitiveScope(options)) {
73
+ return defaults.concat(options);
70
74
  }
71
- return builderModuleScope;
72
- } else {
73
- return void 0;
74
- }
75
- function isPrimitiveScope(items) {
76
- return items.every(function(item) {
77
- return typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]";
78
- });
75
+ return options.reduce(applyScopeOptions, defaults);
79
76
  }
80
- };
81
- config.source.include = createBuilderInclude(config, appContext);
82
- if (bundler === "webpack") {
83
- config.source.moduleScopes = createBuilderModuleScope(config);
77
+ return options(defaults) || defaults;
84
78
  }
85
79
  }
86
80
  export {
81
+ createBuilderModuleScope,
87
82
  initHtmlConfig,
88
83
  initSourceConfig
89
84
  };
@@ -28,56 +28,51 @@ function initSourceConfig(config, appContext, bundler) {
28
28
  if (bundler === "webpack") {
29
29
  config.source.moduleScopes = createBuilderModuleScope(config);
30
30
  }
31
- function createBuilderInclude(config2, appContext2) {
32
- const { include } = config2.source;
33
- const defaultInclude = [
34
- appContext2.internalDirectory
35
- ];
36
- const transformInclude = (include || []).map((include2) => {
37
- if (typeof include2 === "string") {
38
- if (isAbsolute(include2)) {
39
- return include2;
40
- }
41
- return new RegExp(include2);
31
+ }
32
+ function createBuilderInclude(config, appContext) {
33
+ const { include } = config.source;
34
+ const defaultInclude = [
35
+ appContext.internalDirectory
36
+ ];
37
+ const transformInclude = (include || []).map((include2) => {
38
+ if (typeof include2 === "string") {
39
+ if (isAbsolute(include2)) {
40
+ return include2;
42
41
  }
43
- return include2;
44
- }).concat(defaultInclude);
45
- return transformInclude;
42
+ return new RegExp(include2);
43
+ }
44
+ return include2;
45
+ }).concat(defaultInclude);
46
+ return transformInclude;
47
+ }
48
+ function createBuilderModuleScope(config) {
49
+ const { moduleScopes } = config.source;
50
+ if (moduleScopes) {
51
+ const DEFAULT_SCOPES = [
52
+ "./src",
53
+ "./shared",
54
+ /node_modules/
55
+ ];
56
+ const builderModuleScope = applyScopeOptions(DEFAULT_SCOPES, moduleScopes);
57
+ return builderModuleScope;
58
+ } else {
59
+ return void 0;
46
60
  }
47
- function createBuilderModuleScope(config2) {
48
- const { moduleScopes } = config2.source;
49
- if (moduleScopes) {
50
- let builderModuleScope = [];
51
- const DEFAULT_SCOPES = [
52
- "./src",
53
- "./shared",
54
- /node_modules/
55
- ];
56
- if (Array.isArray(moduleScopes)) {
57
- if (isPrimitiveScope(moduleScopes)) {
58
- builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
59
- } else {
60
- builderModuleScope = [
61
- DEFAULT_SCOPES,
62
- ...moduleScopes
63
- ];
64
- }
65
- } else {
66
- builderModuleScope = [
67
- DEFAULT_SCOPES,
68
- moduleScopes
69
- ];
61
+ function isPrimitiveScope(items) {
62
+ return items.every((item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]");
63
+ }
64
+ function applyScopeOptions(defaults, options) {
65
+ if (Array.isArray(options)) {
66
+ if (isPrimitiveScope(options)) {
67
+ return defaults.concat(options);
70
68
  }
71
- return builderModuleScope;
72
- } else {
73
- return void 0;
74
- }
75
- function isPrimitiveScope(items) {
76
- return items.every((item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]");
69
+ return options.reduce(applyScopeOptions, defaults);
77
70
  }
71
+ return options(defaults) || defaults;
78
72
  }
79
73
  }
80
74
  export {
75
+ createBuilderModuleScope,
81
76
  initHtmlConfig,
82
77
  initSourceConfig
83
78
  };
@@ -1,3 +1,4 @@
1
1
  import { AppNormalizedConfig, IAppContext } from '../../types';
2
2
  export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext): import("@modern-js/builder-shared").SharedHtmlConfig;
3
- export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): void;
3
+ export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): void;
4
+ export declare function createBuilderModuleScope(config: AppNormalizedConfig<'webpack'>): (string | RegExp)[] | undefined;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.39.1",
18
+ "version": "2.39.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -72,24 +72,24 @@
72
72
  "es-module-lexer": "^1.1.0",
73
73
  "esbuild": "0.17.19",
74
74
  "@swc/helpers": "0.5.1",
75
- "@modern-js/builder": "2.39.1",
76
- "@modern-js/builder-plugin-esbuild": "2.39.1",
77
- "@modern-js/builder-shared": "2.39.1",
78
- "@modern-js/builder-plugin-node-polyfill": "2.39.1",
79
- "@modern-js/builder-webpack-provider": "2.39.1",
80
- "@modern-js/core": "2.39.1",
81
- "@modern-js/new-action": "2.39.1",
82
- "@modern-js/node-bundle-require": "2.39.1",
83
- "@modern-js/plugin": "2.39.1",
84
- "@modern-js/plugin-data-loader": "2.39.1",
85
- "@modern-js/plugin-i18n": "2.39.1",
86
- "@modern-js/plugin-lint": "2.39.1",
87
- "@modern-js/prod-server": "2.39.1",
88
- "@modern-js/server": "2.39.1",
89
- "@modern-js/types": "2.39.1",
90
- "@modern-js/upgrade": "2.39.1",
91
- "@modern-js/utils": "2.39.1",
92
- "@modern-js/server-core": "2.39.1"
75
+ "@modern-js/builder": "2.39.2",
76
+ "@modern-js/builder-plugin-esbuild": "2.39.2",
77
+ "@modern-js/builder-plugin-node-polyfill": "2.39.2",
78
+ "@modern-js/builder-shared": "2.39.2",
79
+ "@modern-js/builder-webpack-provider": "2.39.2",
80
+ "@modern-js/core": "2.39.2",
81
+ "@modern-js/new-action": "2.39.2",
82
+ "@modern-js/node-bundle-require": "2.39.2",
83
+ "@modern-js/plugin-data-loader": "2.39.2",
84
+ "@modern-js/plugin": "2.39.2",
85
+ "@modern-js/plugin-i18n": "2.39.2",
86
+ "@modern-js/plugin-lint": "2.39.2",
87
+ "@modern-js/prod-server": "2.39.2",
88
+ "@modern-js/server": "2.39.2",
89
+ "@modern-js/types": "2.39.2",
90
+ "@modern-js/upgrade": "2.39.2",
91
+ "@modern-js/utils": "2.39.2",
92
+ "@modern-js/server-core": "2.39.2"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/babel__traverse": "^7.14.2",
@@ -98,13 +98,13 @@
98
98
  "jest": "^29",
99
99
  "typescript": "^5",
100
100
  "webpack": "^5.88.1",
101
- "@modern-js/builder-plugin-swc": "2.39.1",
102
- "@modern-js/builder-rspack-provider": "2.39.1",
103
- "@scripts/build": "2.39.1",
104
- "@scripts/jest-config": "2.39.1"
101
+ "@modern-js/builder-plugin-swc": "2.39.2",
102
+ "@modern-js/builder-rspack-provider": "2.39.2",
103
+ "@scripts/build": "2.39.2",
104
+ "@scripts/jest-config": "2.39.2"
105
105
  },
106
106
  "peerDependencies": {
107
- "@modern-js/builder-rspack-provider": "^2.39.1"
107
+ "@modern-js/builder-rspack-provider": "^2.39.2"
108
108
  },
109
109
  "peerDependenciesMeta": {
110
110
  "@modern-js/builder-rspack-provider": {