@modern-js/app-tools 2.31.3-alpha.0 → 2.31.3-alpha.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Modern.js
3
+ Copyright (c) 2021-present Modern.js
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -106,20 +106,22 @@ const HTML_PARTIALS_EXTENSIONS = [
106
106
  const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
107
107
  const NESTED_ROUTE = {
108
108
  LAYOUT_FILE: "layout",
109
+ LAYOUT_CONFIG_FILE: "layout.config",
109
110
  LAYOUT_LOADER_FILE: "layout.loader",
110
111
  LAYOUT_DATA_FILE: "layout.data",
111
112
  LAYOUT_CLIENT_LOADER: "layout.data.client",
112
113
  PAGE_FILE: "page",
114
+ PAGE_CONFIG_FILE: "page.config",
113
115
  PAGE_LOADER_FILE: "page.loader",
114
- PAGE_DATA_FILE: "layout.data",
116
+ PAGE_DATA_FILE: "page.data",
115
117
  PAGE_CLIENT_LOADER: "page.data.client",
116
- LOADING_FILE: "loading",
117
- ERROR_FILE: "error",
118
- LOADER_FILE: "loader",
119
118
  SPLATE_FILE: "$",
120
119
  SPLATE_LOADER_FILE: "$.loader",
121
- LAYOUT_CONFIG_FILE: "layout.config",
122
- PAGE_CONFIG_FILE: "page.config"
120
+ SPLATE_DATA_FILE: "$.data",
121
+ SPLATE_CLIENT_DATA: "$.data.client",
122
+ LOADING_FILE: "loading",
123
+ ERROR_FILE: "error",
124
+ LOADER_FILE: "loader"
123
125
  };
124
126
  const APP_CONFIG_NAME = "config";
125
127
  const APP_INIT_EXPORTED = "init";
@@ -120,6 +120,8 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
120
120
  let pageLoaderFile = "";
121
121
  let pageRoute = null;
122
122
  let splatLoaderFile = "";
123
+ let splatClientData = "";
124
+ let splatData = "";
123
125
  let splatRoute = null;
124
126
  let pageConfigFile = "";
125
127
  const items = await _utils.fs.readdir(dirname);
@@ -185,6 +187,12 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
185
187
  if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_LOADER_FILE) {
186
188
  splatLoaderFile = itemPath;
187
189
  }
190
+ if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_CLIENT_DATA) {
191
+ splatClientData = itemPath;
192
+ }
193
+ if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_DATA_FILE) {
194
+ splatData = itemPath;
195
+ }
188
196
  if (itemWithoutExt === _constants.NESTED_ROUTE.SPLATE_FILE) {
189
197
  var _route_children2;
190
198
  splatRoute = createRoute({
@@ -194,6 +202,12 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
194
202
  if (splatLoaderFile) {
195
203
  splatRoute.loader = splatLoaderFile;
196
204
  }
205
+ if (splatClientData) {
206
+ splatRoute.clientData = splatClientData;
207
+ }
208
+ if (splatData) {
209
+ splatRoute.data = splatData;
210
+ }
197
211
  (_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(splatRoute);
198
212
  }
199
213
  if (itemWithoutExt === _constants.NESTED_ROUTE.LOADING_FILE) {
package/dist/cjs/index.js CHANGED
@@ -219,10 +219,7 @@ const appTools = (options = {
219
219
  },
220
220
  async beforeGenerateRoutes({ entrypoint, code }) {
221
221
  const { distDirectory } = api.useAppContext();
222
- if (!_utils.fs.existsSync(distDirectory)) {
223
- await _utils.fs.mkdir(distDirectory);
224
- }
225
- await _utils.fs.writeJSON(_path.default.resolve(distDirectory, _utils.NESTED_ROUTE_SPEC_FILE), nestedRoutes);
222
+ await _utils.fs.outputJSON(_path.default.resolve(distDirectory, _utils.NESTED_ROUTE_SPEC_FILE), nestedRoutes);
226
223
  return {
227
224
  entrypoint,
228
225
  code
@@ -27,20 +27,22 @@ export var HTML_PARTIALS_EXTENSIONS = [
27
27
  export var FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
28
28
  export var NESTED_ROUTE = {
29
29
  LAYOUT_FILE: "layout",
30
+ LAYOUT_CONFIG_FILE: "layout.config",
30
31
  LAYOUT_LOADER_FILE: "layout.loader",
31
32
  LAYOUT_DATA_FILE: "layout.data",
32
33
  LAYOUT_CLIENT_LOADER: "layout.data.client",
33
34
  PAGE_FILE: "page",
35
+ PAGE_CONFIG_FILE: "page.config",
34
36
  PAGE_LOADER_FILE: "page.loader",
35
- PAGE_DATA_FILE: "layout.data",
37
+ PAGE_DATA_FILE: "page.data",
36
38
  PAGE_CLIENT_LOADER: "page.data.client",
37
- LOADING_FILE: "loading",
38
- ERROR_FILE: "error",
39
- LOADER_FILE: "loader",
40
39
  SPLATE_FILE: "$",
41
40
  SPLATE_LOADER_FILE: "$.loader",
42
- LAYOUT_CONFIG_FILE: "layout.config",
43
- PAGE_CONFIG_FILE: "page.config"
41
+ SPLATE_DATA_FILE: "$.data",
42
+ SPLATE_CLIENT_DATA: "$.data.client",
43
+ LOADING_FILE: "loading",
44
+ ERROR_FILE: "error",
45
+ LOADER_FILE: "loader"
44
46
  };
45
47
  export var APP_CONFIG_NAME = "config";
46
48
  export var APP_INIT_EXPORTED = "init";
@@ -73,7 +73,7 @@ export var optimizeRoute = function(routeTree) {
73
73
  };
74
74
  export var walk = function() {
75
75
  var _ref = _async_to_generator(function(dirname, rootDir, alias, entryName, isMainEntry, oldVersion) {
76
- var _routePath, _finalRoute_children, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, pageConfigFile, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory1, childRoute, _route_children, _route_children1, _route_children2, err, finalRoute, childRoutes, childRoute1, _$path, optimizedRoutes;
76
+ var _routePath, _finalRoute_children, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatClientData, splatData, splatRoute, pageConfigFile, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory1, childRoute, _route_children, _route_children1, _route_children2, err, finalRoute, childRoutes, childRoute1, _$path, optimizedRoutes;
77
77
  return _ts_generator(this, function(_state) {
78
78
  switch (_state.label) {
79
79
  case 0:
@@ -119,6 +119,8 @@ export var walk = function() {
119
119
  pageLoaderFile = "";
120
120
  pageRoute = null;
121
121
  splatLoaderFile = "";
122
+ splatClientData = "";
123
+ splatData = "";
122
124
  splatRoute = null;
123
125
  pageConfigFile = "";
124
126
  return [
@@ -224,6 +226,12 @@ export var walk = function() {
224
226
  if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
225
227
  splatLoaderFile = itemPath;
226
228
  }
229
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_CLIENT_DATA) {
230
+ splatClientData = itemPath;
231
+ }
232
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_DATA_FILE) {
233
+ splatData = itemPath;
234
+ }
227
235
  if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
228
236
  ;
229
237
  splatRoute = createRoute({
@@ -233,6 +241,12 @@ export var walk = function() {
233
241
  if (splatLoaderFile) {
234
242
  splatRoute.loader = splatLoaderFile;
235
243
  }
244
+ if (splatClientData) {
245
+ splatRoute.clientData = splatClientData;
246
+ }
247
+ if (splatData) {
248
+ splatRoute.data = splatData;
249
+ }
236
250
  (_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(splatRoute);
237
251
  }
238
252
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
package/dist/esm/index.js CHANGED
@@ -626,24 +626,11 @@ export var appTools = function() {
626
626
  switch (_state.label) {
627
627
  case 0:
628
628
  distDirectory = api.useAppContext().distDirectory;
629
- if (!!fs.existsSync(distDirectory))
630
- return [
631
- 3,
632
- 2
633
- ];
634
629
  return [
635
630
  4,
636
- fs.mkdir(distDirectory)
631
+ fs.outputJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutes)
637
632
  ];
638
633
  case 1:
639
- _state.sent();
640
- _state.label = 2;
641
- case 2:
642
- return [
643
- 4,
644
- fs.writeJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutes)
645
- ];
646
- case 3:
647
634
  _state.sent();
648
635
  return [
649
636
  2,
@@ -27,20 +27,22 @@ export const HTML_PARTIALS_EXTENSIONS = [
27
27
  export const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
28
28
  export const NESTED_ROUTE = {
29
29
  LAYOUT_FILE: "layout",
30
+ LAYOUT_CONFIG_FILE: "layout.config",
30
31
  LAYOUT_LOADER_FILE: "layout.loader",
31
32
  LAYOUT_DATA_FILE: "layout.data",
32
33
  LAYOUT_CLIENT_LOADER: "layout.data.client",
33
34
  PAGE_FILE: "page",
35
+ PAGE_CONFIG_FILE: "page.config",
34
36
  PAGE_LOADER_FILE: "page.loader",
35
- PAGE_DATA_FILE: "layout.data",
37
+ PAGE_DATA_FILE: "page.data",
36
38
  PAGE_CLIENT_LOADER: "page.data.client",
37
- LOADING_FILE: "loading",
38
- ERROR_FILE: "error",
39
- LOADER_FILE: "loader",
40
39
  SPLATE_FILE: "$",
41
40
  SPLATE_LOADER_FILE: "$.loader",
42
- LAYOUT_CONFIG_FILE: "layout.config",
43
- PAGE_CONFIG_FILE: "page.config"
41
+ SPLATE_DATA_FILE: "$.data",
42
+ SPLATE_CLIENT_DATA: "$.data.client",
43
+ LOADING_FILE: "loading",
44
+ ERROR_FILE: "error",
45
+ LOADER_FILE: "loader"
44
46
  };
45
47
  export const APP_CONFIG_NAME = "config";
46
48
  export const APP_INIT_EXPORTED = "init";
@@ -97,6 +97,8 @@ export const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldV
97
97
  let pageLoaderFile = "";
98
98
  let pageRoute = null;
99
99
  let splatLoaderFile = "";
100
+ let splatClientData = "";
101
+ let splatData = "";
100
102
  let splatRoute = null;
101
103
  let pageConfigFile = "";
102
104
  const items = await fs.readdir(dirname);
@@ -162,6 +164,12 @@ export const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldV
162
164
  if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
163
165
  splatLoaderFile = itemPath;
164
166
  }
167
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_CLIENT_DATA) {
168
+ splatClientData = itemPath;
169
+ }
170
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_DATA_FILE) {
171
+ splatData = itemPath;
172
+ }
165
173
  if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
166
174
  var _route_children2;
167
175
  splatRoute = createRoute({
@@ -171,6 +179,12 @@ export const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldV
171
179
  if (splatLoaderFile) {
172
180
  splatRoute.loader = splatLoaderFile;
173
181
  }
182
+ if (splatClientData) {
183
+ splatRoute.clientData = splatClientData;
184
+ }
185
+ if (splatData) {
186
+ splatRoute.data = splatData;
187
+ }
174
188
  (_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(splatRoute);
175
189
  }
176
190
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
@@ -185,10 +185,7 @@ export const appTools = (options = {
185
185
  },
186
186
  async beforeGenerateRoutes({ entrypoint, code }) {
187
187
  const { distDirectory } = api.useAppContext();
188
- if (!fs.existsSync(distDirectory)) {
189
- await fs.mkdir(distDirectory);
190
- }
191
- await fs.writeJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutes);
188
+ await fs.outputJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutes);
192
189
  return {
193
190
  entrypoint,
194
191
  code
@@ -18,20 +18,22 @@ export declare const HTML_PARTIALS_EXTENSIONS: string[];
18
18
  export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
19
19
  export declare const NESTED_ROUTE: {
20
20
  LAYOUT_FILE: string;
21
+ LAYOUT_CONFIG_FILE: string;
21
22
  LAYOUT_LOADER_FILE: string;
22
23
  LAYOUT_DATA_FILE: string;
23
24
  LAYOUT_CLIENT_LOADER: string;
24
25
  PAGE_FILE: string;
26
+ PAGE_CONFIG_FILE: string;
25
27
  PAGE_LOADER_FILE: string;
26
28
  PAGE_DATA_FILE: string;
27
29
  PAGE_CLIENT_LOADER: string;
30
+ SPLATE_FILE: string;
31
+ SPLATE_LOADER_FILE: string;
32
+ SPLATE_DATA_FILE: string;
33
+ SPLATE_CLIENT_DATA: string;
28
34
  LOADING_FILE: string;
29
35
  ERROR_FILE: string;
30
36
  LOADER_FILE: string;
31
- SPLATE_FILE: string;
32
- SPLATE_LOADER_FILE: string;
33
- LAYOUT_CONFIG_FILE: string;
34
- PAGE_CONFIG_FILE: string;
35
37
  };
36
38
  export declare const APP_CONFIG_NAME = "config";
37
39
  export declare const APP_INIT_EXPORTED = "init";
@@ -1,6 +1,6 @@
1
1
  import type { UserConfigExport } from '@modern-js/core';
2
2
  import type { AppLegacyUserConfig, AppUserConfig } from './types';
3
- export declare const defineConfig: <B extends "webpack" | "rspack" = "webpack">(config: UserConfigExport<AppUserConfig<B>>) => UserConfigExport<AppUserConfig<B>>;
3
+ export declare const defineConfig: <B extends "rspack" | "webpack" = "webpack">(config: UserConfigExport<AppUserConfig<B>>) => UserConfigExport<AppUserConfig<B>>;
4
4
  /**
5
5
  * Recommend use `defineConfig` first.
6
6
  *
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.31.3-alpha.0",
18
+ "version": "2.31.3-alpha.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -73,24 +73,24 @@
73
73
  "esbuild": "0.17.19",
74
74
  "rspack-plugin-virtual-module": "0.1.7",
75
75
  "@swc/helpers": "0.5.1",
76
+ "@modern-js/builder-plugin-esbuild": "2.31.2",
76
77
  "@modern-js/builder": "2.31.2",
77
78
  "@modern-js/builder-shared": "2.31.2",
78
79
  "@modern-js/builder-webpack-provider": "2.31.2",
79
80
  "@modern-js/core": "2.31.2",
81
+ "@modern-js/new-action": "2.31.2",
80
82
  "@modern-js/node-bundle-require": "2.31.2",
83
+ "@modern-js/builder-plugin-node-polyfill": "2.31.2",
81
84
  "@modern-js/plugin-i18n": "2.31.2",
82
- "@modern-js/plugin": "2.31.2",
83
85
  "@modern-js/plugin-lint": "2.31.2",
84
- "@modern-js/prod-server": "2.31.2",
85
86
  "@modern-js/server": "2.31.2",
86
- "@modern-js/upgrade": "2.31.2",
87
- "@modern-js/types": "2.31.2",
88
- "@modern-js/utils": "2.31.2",
87
+ "@modern-js/plugin": "2.31.2",
88
+ "@modern-js/plugin-data-loader": "2.31.2",
89
89
  "@modern-js/server-core": "2.31.2",
90
- "@modern-js/new-action": "2.31.2",
91
- "@modern-js/builder-plugin-esbuild": "2.31.2",
92
- "@modern-js/builder-plugin-node-polyfill": "2.31.2",
93
- "@modern-js/plugin-data-loader": "2.31.2"
90
+ "@modern-js/prod-server": "2.31.2",
91
+ "@modern-js/utils": "2.31.2",
92
+ "@modern-js/types": "2.31.2",
93
+ "@modern-js/upgrade": "2.31.2"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@types/babel__traverse": "^7.14.2",
@@ -100,9 +100,9 @@
100
100
  "typescript": "^5",
101
101
  "webpack": "^5.88.1",
102
102
  "@modern-js/builder-rspack-provider": "2.31.2",
103
+ "@modern-js/builder-plugin-swc": "2.31.2",
103
104
  "@scripts/build": "2.31.1",
104
- "@scripts/jest-config": "2.31.1",
105
- "@modern-js/builder-plugin-swc": "2.31.2"
105
+ "@scripts/jest-config": "2.31.1"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "@modern-js/builder-rspack-provider": "^2.31.2"