@modern-js/app-tools 2.3.0 → 2.3.1-alpha.0

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.
@@ -23,7 +23,9 @@ const NESTED_ROUTE = {
23
23
  PAGE_LOADER_FILE: "page.loader",
24
24
  LOADING_FILE: "loading",
25
25
  ERROR_FILE: "error",
26
- LOADER_FILE: "loader"
26
+ LOADER_FILE: "loader",
27
+ SPLATE_FILE: "$",
28
+ SPLATE_LOADER_FILE: "$.loader"
27
29
  };
28
30
  const APP_CONFIG_NAME = "config";
29
31
  const APP_INIT_EXPORTED = "init";
@@ -64,7 +64,7 @@ const createRoute = (routeInfo, rootDir, filename, entryName) => {
64
64
  });
65
65
  };
66
66
  const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, function* () {
67
- var _a, _b, _c;
67
+ var _a, _b, _c, _d;
68
68
  if (!(yield fs.pathExists(dirname))) {
69
69
  return null;
70
70
  }
@@ -90,6 +90,8 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
90
90
  };
91
91
  let pageLoaderFile = "";
92
92
  let pageRoute = null;
93
+ let splatLoaderFile = "";
94
+ let splatRoute = null;
93
95
  const items = yield fs.readdir(dirname);
94
96
  for (const item of items) {
95
97
  const itemPath = path.join(dirname, item);
@@ -130,6 +132,24 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
130
132
  }
131
133
  (_b = route.children) == null ? void 0 : _b.push(pageRoute);
132
134
  }
135
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
136
+ splatLoaderFile = itemPath;
137
+ }
138
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
139
+ splatRoute = createRoute(
140
+ {
141
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name),
142
+ path: "*"
143
+ },
144
+ rootDir,
145
+ itemPath,
146
+ entryName
147
+ );
148
+ if (splatLoaderFile) {
149
+ splatRoute.loader = splatLoaderFile;
150
+ }
151
+ (_c = route.children) == null ? void 0 : _c.push(splatRoute);
152
+ }
133
153
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
134
154
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
135
155
  }
@@ -137,7 +157,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
137
157
  route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
138
158
  }
139
159
  }
140
- const finalRoute = createRoute(
160
+ let finalRoute = createRoute(
141
161
  route,
142
162
  rootDir,
143
163
  path.join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`),
@@ -146,10 +166,19 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
146
166
  if (isPathlessLayout) {
147
167
  delete finalRoute.path;
148
168
  }
149
- route.children = (_c = route.children) == null ? void 0 : _c.filter((childRoute) => childRoute);
169
+ route.children = (_d = route.children) == null ? void 0 : _d.filter((childRoute) => childRoute);
150
170
  if (route.children && route.children.length === 0 && !route.index) {
151
171
  return null;
152
172
  }
173
+ if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
174
+ const childRoute = finalRoute.children[0];
175
+ if (childRoute.path === "*") {
176
+ const path2 = (finalRoute.path || "") + (childRoute.path || "");
177
+ finalRoute = __spreadProps(__spreadValues({}, childRoute), {
178
+ path: path2
179
+ });
180
+ }
181
+ }
153
182
  return finalRoute;
154
183
  });
155
184
  export {
@@ -198,7 +198,6 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
198
198
  import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"
199
199
  `;
200
200
  let rootLayoutCode = ``;
201
- let componentLoaderPath = "";
202
201
  const getDataLoaderPath = (loaderId) => {
203
202
  if (!ssrMode) {
204
203
  return "";
@@ -211,12 +210,6 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
211
210
  }
212
211
  return dataLoaderPath;
213
212
  };
214
- if (ssrMode) {
215
- componentLoaderPath = `${path.join(
216
- __dirname,
217
- "../builder/loaders/routerLoader"
218
- )}!`;
219
- }
220
213
  const traverseRouteTree = (route) => {
221
214
  var _a;
222
215
  let children;
@@ -252,10 +245,10 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
252
245
  rootLayoutCode = `import RootLayout from '${route._component}'`;
253
246
  component = `RootLayout`;
254
247
  } else if (ssrMode === "string") {
255
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}')`;
248
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}')`;
256
249
  component = `loadable(${lazyImport})`;
257
250
  } else {
258
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}')`;
251
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}')`;
259
252
  component = `lazy(${lazyImport})`;
260
253
  }
261
254
  }
@@ -66,7 +66,9 @@ const NESTED_ROUTE = {
66
66
  PAGE_LOADER_FILE: "page.loader",
67
67
  LOADING_FILE: "loading",
68
68
  ERROR_FILE: "error",
69
- LOADER_FILE: "loader"
69
+ LOADER_FILE: "loader",
70
+ SPLATE_FILE: "$",
71
+ SPLATE_LOADER_FILE: "$.loader"
70
72
  };
71
73
  const APP_CONFIG_NAME = "config";
72
74
  const APP_INIT_EXPORTED = "init";
@@ -90,7 +90,7 @@ const createRoute = (routeInfo, rootDir, filename, entryName) => {
90
90
  });
91
91
  };
92
92
  const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, function* () {
93
- var _a, _b, _c;
93
+ var _a, _b, _c, _d;
94
94
  if (!(yield import_utils.fs.pathExists(dirname))) {
95
95
  return null;
96
96
  }
@@ -116,6 +116,8 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
116
116
  };
117
117
  let pageLoaderFile = "";
118
118
  let pageRoute = null;
119
+ let splatLoaderFile = "";
120
+ let splatRoute = null;
119
121
  const items = yield import_utils.fs.readdir(dirname);
120
122
  for (const item of items) {
121
123
  const itemPath = path.join(dirname, item);
@@ -156,6 +158,24 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
156
158
  }
157
159
  (_b = route.children) == null ? void 0 : _b.push(pageRoute);
158
160
  }
161
+ if (itemWithoutExt === import_constants.NESTED_ROUTE.SPLATE_LOADER_FILE) {
162
+ splatLoaderFile = itemPath;
163
+ }
164
+ if (itemWithoutExt === import_constants.NESTED_ROUTE.SPLATE_FILE) {
165
+ splatRoute = createRoute(
166
+ {
167
+ _component: (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name),
168
+ path: "*"
169
+ },
170
+ rootDir,
171
+ itemPath,
172
+ entryName
173
+ );
174
+ if (splatLoaderFile) {
175
+ splatRoute.loader = splatLoaderFile;
176
+ }
177
+ (_c = route.children) == null ? void 0 : _c.push(splatRoute);
178
+ }
159
179
  if (itemWithoutExt === import_constants.NESTED_ROUTE.LOADING_FILE) {
160
180
  route.loading = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
161
181
  }
@@ -163,7 +183,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
163
183
  route.error = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
164
184
  }
165
185
  }
166
- const finalRoute = createRoute(
186
+ let finalRoute = createRoute(
167
187
  route,
168
188
  rootDir,
169
189
  path.join(dirname, `${import_constants.NESTED_ROUTE.LAYOUT_FILE}.ts`),
@@ -172,10 +192,19 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
172
192
  if (isPathlessLayout) {
173
193
  delete finalRoute.path;
174
194
  }
175
- route.children = (_c = route.children) == null ? void 0 : _c.filter((childRoute) => childRoute);
195
+ route.children = (_d = route.children) == null ? void 0 : _d.filter((childRoute) => childRoute);
176
196
  if (route.children && route.children.length === 0 && !route.index) {
177
197
  return null;
178
198
  }
199
+ if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
200
+ const childRoute = finalRoute.children[0];
201
+ if (childRoute.path === "*") {
202
+ const path2 = (finalRoute.path || "") + (childRoute.path || "");
203
+ finalRoute = __spreadProps(__spreadValues({}, childRoute), {
204
+ path: path2
205
+ });
206
+ }
207
+ }
179
208
  return finalRoute;
180
209
  });
181
210
  // Annotate the CommonJS export names for ESM import in node:
@@ -228,7 +228,6 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
228
228
  import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"
229
229
  `;
230
230
  let rootLayoutCode = ``;
231
- let componentLoaderPath = "";
232
231
  const getDataLoaderPath = (loaderId) => {
233
232
  if (!ssrMode) {
234
233
  return "";
@@ -241,12 +240,6 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
241
240
  }
242
241
  return dataLoaderPath;
243
242
  };
244
- if (ssrMode) {
245
- componentLoaderPath = `${import_path.default.join(
246
- __dirname,
247
- "../builder/loaders/routerLoader"
248
- )}!`;
249
- }
250
243
  const traverseRouteTree = (route) => {
251
244
  var _a;
252
245
  let children;
@@ -282,10 +275,10 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
282
275
  rootLayoutCode = `import RootLayout from '${route._component}'`;
283
276
  component = `RootLayout`;
284
277
  } else if (ssrMode === "string") {
285
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}')`;
278
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}')`;
286
279
  component = `loadable(${lazyImport})`;
287
280
  } else {
288
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}')`;
281
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}')`;
289
282
  component = `lazy(${lazyImport})`;
290
283
  }
291
284
  }
@@ -32,7 +32,9 @@ var NESTED_ROUTE = {
32
32
  PAGE_LOADER_FILE: "page.loader",
33
33
  LOADING_FILE: "loading",
34
34
  ERROR_FILE: "error",
35
- LOADER_FILE: "loader"
35
+ LOADER_FILE: "loader",
36
+ SPLATE_FILE: "$",
37
+ SPLATE_LOADER_FILE: "$.loader"
36
38
  };
37
39
  var APP_CONFIG_NAME = "config";
38
40
  var APP_INIT_EXPORTED = "init";
@@ -197,7 +197,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
197
197
  };
198
198
  var walk = function() {
199
199
  var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
200
- var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, err, finalRoute;
200
+ var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, err, finalRoute, childRoute1, path2;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -242,6 +242,8 @@ var walk = function() {
242
242
  };
243
243
  pageLoaderFile = "";
244
244
  pageRoute = null;
245
+ splatLoaderFile = "";
246
+ splatRoute = null;
245
247
  return [
246
248
  4,
247
249
  fs.readdir(dirname)
@@ -317,6 +319,20 @@ var walk = function() {
317
319
  }
318
320
  (ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
319
321
  }
322
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
323
+ splatLoaderFile = itemPath;
324
+ }
325
+ if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
326
+ ;
327
+ splatRoute = createRoute({
328
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name),
329
+ path: "*"
330
+ }, rootDir, itemPath, entryName);
331
+ if (splatLoaderFile) {
332
+ splatRoute.loader = splatLoaderFile;
333
+ }
334
+ (ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
335
+ }
320
336
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
321
337
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
322
338
  }
@@ -370,6 +386,15 @@ var walk = function() {
370
386
  null
371
387
  ];
372
388
  }
389
+ if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
390
+ childRoute1 = finalRoute.children[0];
391
+ if (childRoute1.path === "*") {
392
+ path2 = (finalRoute.path || "") + (childRoute1.path || "");
393
+ finalRoute = _objectSpreadProps(_objectSpread({}, childRoute1), {
394
+ path: path2
395
+ });
396
+ }
397
+ }
373
398
  return [
374
399
  2,
375
400
  finalRoute
@@ -296,7 +296,7 @@ var routesForServer = function(param) {
296
296
  };
297
297
  var fileSystemRoutes = function() {
298
298
  var _ref = _asyncToGenerator(function(param) {
299
- var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, componentLoaderPath, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
299
+ var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
300
300
  return __generator(this, function(_state) {
301
301
  switch(_state.label){
302
302
  case 0:
@@ -308,7 +308,6 @@ var fileSystemRoutes = function() {
308
308
  loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
309
309
  importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
310
310
  rootLayoutCode = "";
311
- componentLoaderPath = "";
312
311
  getDataLoaderPath = function(loaderId) {
313
312
  if (!ssrMode) {
314
313
  return "";
@@ -319,9 +318,6 @@ var fileSystemRoutes = function() {
319
318
  }
320
319
  return dataLoaderPath;
321
320
  };
322
- if (ssrMode) {
323
- componentLoaderPath = "".concat(path.join(__dirname, "../builder/loaders/routerLoader"), "!");
324
- }
325
321
  traverseRouteTree = function(route) {
326
322
  var children;
327
323
  if ("children" in route && route.children) {
@@ -357,10 +353,10 @@ var fileSystemRoutes = function() {
357
353
  rootLayoutCode = "import RootLayout from '".concat(route._component, "'");
358
354
  component = "RootLayout";
359
355
  } else if (ssrMode === "string") {
360
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
356
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
361
357
  component = "loadable(".concat(lazyImport, ")");
362
358
  } else {
363
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
359
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
364
360
  component = "lazy(".concat(lazyImport, ")");
365
361
  }
366
362
  }
@@ -24,6 +24,8 @@ export declare const NESTED_ROUTE: {
24
24
  LOADING_FILE: string;
25
25
  ERROR_FILE: string;
26
26
  LOADER_FILE: string;
27
+ SPLATE_FILE: string;
28
+ SPLATE_LOADER_FILE: string;
27
29
  };
28
30
  export declare const APP_CONFIG_NAME = "config";
29
31
  export declare const APP_INIT_EXPORTED = "init";
@@ -1,5 +1,6 @@
1
- import { AppUserConfig, AppLegacyUserConfig } from './types';
2
- export declare const defineConfig: (config: AppUserConfig) => AppUserConfig;
1
+ import type { UserConfigExport } from '@modern-js/core';
2
+ import type { AppUserConfig, AppLegacyUserConfig } from './types';
3
+ export declare const defineConfig: (config: UserConfigExport<AppUserConfig>) => UserConfigExport<AppUserConfig>;
3
4
  /**
4
5
  * @deprecated
5
6
  * Using defineConfig first.
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.3.0",
14
+ "version": "2.3.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -63,8 +63,6 @@
63
63
  "@babel/runtime": "^7.18.0",
64
64
  "@babel/traverse": "^7.18.0",
65
65
  "@babel/types": "^7.18.0",
66
- "es-module-lexer": "^1.1.0",
67
- "esbuild": "0.15.7",
68
66
  "@modern-js/builder": "2.3.0",
69
67
  "@modern-js/builder-plugin-esbuild": "2.3.0",
70
68
  "@modern-js/builder-plugin-node-polyfill": "2.3.0",
@@ -81,19 +79,21 @@
81
79
  "@modern-js/server": "2.3.0",
82
80
  "@modern-js/types": "2.3.0",
83
81
  "@modern-js/upgrade": "2.3.0",
84
- "@modern-js/utils": "2.3.0"
82
+ "@modern-js/utils": "2.3.0",
83
+ "es-module-lexer": "^1.1.0",
84
+ "esbuild": "0.15.7"
85
85
  },
86
86
  "devDependencies": {
87
+ "@modern-js/builder-plugin-swc": "2.3.0",
88
+ "@modern-js/server-core": "2.3.0",
89
+ "@scripts/build": "2.3.0",
90
+ "@scripts/jest-config": "2.3.0",
87
91
  "@types/babel__traverse": "^7.14.2",
88
92
  "@types/jest": "^27",
89
93
  "@types/node": "^14",
90
94
  "jest": "^27",
91
95
  "typescript": "^4",
92
- "webpack": "^5.75.0",
93
- "@modern-js/builder-plugin-swc": "2.3.0",
94
- "@modern-js/server-core": "2.3.0",
95
- "@scripts/jest-config": "2.3.0",
96
- "@scripts/build": "2.3.0"
96
+ "webpack": "^5.75.0"
97
97
  },
98
98
  "sideEffects": false,
99
99
  "publishConfig": {
@@ -1,17 +0,0 @@
1
- import { slash } from "@modern-js/utils";
2
- function loader(source) {
3
- this.cacheable();
4
- const { target } = this._compiler.options;
5
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
6
- return source;
7
- }
8
- const { resourcePath } = this;
9
- const code = `
10
- export { default } from "${slash(resourcePath)}";
11
- `;
12
- return code;
13
- }
14
- var routerLoader_default = loader;
15
- export {
16
- routerLoader_default as default
17
- };
@@ -1,38 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var routerLoader_exports = {};
19
- __export(routerLoader_exports, {
20
- default: () => routerLoader_default
21
- });
22
- module.exports = __toCommonJS(routerLoader_exports);
23
- var import_utils = require("@modern-js/utils");
24
- function loader(source) {
25
- this.cacheable();
26
- const { target } = this._compiler.options;
27
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
28
- return source;
29
- }
30
- const { resourcePath } = this;
31
- const code = `
32
- export { default } from "${(0, import_utils.slash)(resourcePath)}";
33
- `;
34
- return code;
35
- }
36
- var routerLoader_default = loader;
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {});
@@ -1,13 +0,0 @@
1
- import { slash } from "@modern-js/utils";
2
- function loader(source) {
3
- this.cacheable();
4
- var target = this._compiler.options.target;
5
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
6
- return source;
7
- }
8
- var resourcePath = this.resourcePath;
9
- var code = '\n export { default } from "'.concat(slash(resourcePath), '";\n ');
10
- return code;
11
- }
12
- var routerLoader_default = loader;
13
- export { routerLoader_default as default };
@@ -1,3 +0,0 @@
1
- import type { LoaderContext } from 'webpack';
2
- declare function loader(this: LoaderContext<void>, source: string): string;
3
- export default loader;