@granite-js/plugin-router 3.0.2 → 3.0.4
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 +13 -0
- package/dist/index.cjs +2 -43
- package/dist/index.js +1 -41
- package/dist/mpack.cjs +1 -1
- package/dist/{watchRouter-CfoP6FM2.cjs → watchRouter-B9ee8-06.cjs} +0 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @granite-js/plugin-router
|
|
2
2
|
|
|
3
|
+
## 3.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @granite-js/plugin-core@3.0.4
|
|
8
|
+
|
|
9
|
+
## 3.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8214426: Keep the router plugin focused on route generation and watching. Remove automatic `require.context` replacement with `import.meta.glob`; applications should manage page imports explicitly.
|
|
14
|
+
- @granite-js/plugin-core@3.0.3
|
|
15
|
+
|
|
3
16
|
## 3.0.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_watchRouter = require('./watchRouter-
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
node_path = require_watchRouter.__toESM(node_path);
|
|
2
|
+
const require_watchRouter = require('./watchRouter-B9ee8-06.cjs');
|
|
5
3
|
|
|
6
4
|
//#region src/next/index.ts
|
|
7
|
-
const REQUIRE_CONTEXT_IMPORT = /^(?:\.{1,2}\/)+(?:[^/]+\/)*require\.context(?:\.[^/]+)*$/;
|
|
8
|
-
const REQUIRE_CONTEXT_MODULE = /[\\/]require\.context(?:\.[^/\\]+)*$/;
|
|
9
5
|
function router() {
|
|
10
|
-
return [
|
|
11
|
-
routeGenerator(),
|
|
12
|
-
routeWatcher(),
|
|
13
|
-
pageImports()
|
|
14
|
-
];
|
|
6
|
+
return [routeGenerator(), routeWatcher()];
|
|
15
7
|
}
|
|
16
8
|
function routeGenerator() {
|
|
17
9
|
return {
|
|
@@ -32,39 +24,6 @@ function routeWatcher() {
|
|
|
32
24
|
}
|
|
33
25
|
};
|
|
34
26
|
}
|
|
35
|
-
function pageImports() {
|
|
36
|
-
return {
|
|
37
|
-
name: "granite:router:page-imports",
|
|
38
|
-
resolveId: {
|
|
39
|
-
filter: { id: REQUIRE_CONTEXT_IMPORT },
|
|
40
|
-
handler(source, importer) {
|
|
41
|
-
return importer == null ? null : node_path.resolve(node_path.dirname(importer), source);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
load: {
|
|
45
|
-
filter: { id: REQUIRE_CONTEXT_MODULE },
|
|
46
|
-
handler() {
|
|
47
|
-
return `
|
|
48
|
-
const modules = import.meta.glob('./**/*.{js,jsx,ts,tsx}', { base: './pages', eager: true });
|
|
49
|
-
|
|
50
|
-
export const context = Object.assign(
|
|
51
|
-
(key) => {
|
|
52
|
-
if (!Object.prototype.hasOwnProperty.call(modules, key)) {
|
|
53
|
-
throw new Error(\`Unknown screen: \${key}\`);
|
|
54
|
-
}
|
|
55
|
-
return modules[key];
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
keys: () => Object.keys(modules),
|
|
59
|
-
resolve: (key) => key,
|
|
60
|
-
id: 'pages',
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
27
|
|
|
69
28
|
//#endregion
|
|
70
29
|
exports.router = router;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { n as generateRouterFile, t as watchRouter } from "./watchRouter-opiv55Vn.js";
|
|
2
|
-
import * as path from "node:path";
|
|
3
2
|
|
|
4
3
|
//#region src/next/index.ts
|
|
5
|
-
const REQUIRE_CONTEXT_IMPORT = /^(?:\.{1,2}\/)+(?:[^/]+\/)*require\.context(?:\.[^/]+)*$/;
|
|
6
|
-
const REQUIRE_CONTEXT_MODULE = /[\\/]require\.context(?:\.[^/\\]+)*$/;
|
|
7
4
|
function router() {
|
|
8
|
-
return [
|
|
9
|
-
routeGenerator(),
|
|
10
|
-
routeWatcher(),
|
|
11
|
-
pageImports()
|
|
12
|
-
];
|
|
5
|
+
return [routeGenerator(), routeWatcher()];
|
|
13
6
|
}
|
|
14
7
|
function routeGenerator() {
|
|
15
8
|
return {
|
|
@@ -30,39 +23,6 @@ function routeWatcher() {
|
|
|
30
23
|
}
|
|
31
24
|
};
|
|
32
25
|
}
|
|
33
|
-
function pageImports() {
|
|
34
|
-
return {
|
|
35
|
-
name: "granite:router:page-imports",
|
|
36
|
-
resolveId: {
|
|
37
|
-
filter: { id: REQUIRE_CONTEXT_IMPORT },
|
|
38
|
-
handler(source, importer) {
|
|
39
|
-
return importer == null ? null : path.resolve(path.dirname(importer), source);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
load: {
|
|
43
|
-
filter: { id: REQUIRE_CONTEXT_MODULE },
|
|
44
|
-
handler() {
|
|
45
|
-
return `
|
|
46
|
-
const modules = import.meta.glob('./**/*.{js,jsx,ts,tsx}', { base: './pages', eager: true });
|
|
47
|
-
|
|
48
|
-
export const context = Object.assign(
|
|
49
|
-
(key) => {
|
|
50
|
-
if (!Object.prototype.hasOwnProperty.call(modules, key)) {
|
|
51
|
-
throw new Error(\`Unknown screen: \${key}\`);
|
|
52
|
-
}
|
|
53
|
-
return modules[key];
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
keys: () => Object.keys(modules),
|
|
57
|
-
resolve: (key) => key,
|
|
58
|
-
id: 'pages',
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
`;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
26
|
|
|
67
27
|
//#endregion
|
|
68
28
|
export { router };
|
package/dist/mpack.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_watchRouter = require('./watchRouter-
|
|
2
|
+
const require_watchRouter = require('./watchRouter-B9ee8-06.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/routerPlugin.ts
|
|
5
5
|
const DEFAULT_OPTIONS = { watch: true };
|
|
@@ -256,12 +256,6 @@ function watchRouter(root = process.cwd()) {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
//#endregion
|
|
259
|
-
Object.defineProperty(exports, '__toESM', {
|
|
260
|
-
enumerable: true,
|
|
261
|
-
get: function () {
|
|
262
|
-
return __toESM;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
259
|
Object.defineProperty(exports, 'generateRouterFile', {
|
|
266
260
|
enumerable: true,
|
|
267
261
|
get: function () {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/plugin-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.4",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "A Route Generator for Granite project",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"vitest": "^4.0.12"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@granite-js/plugin-core": "3.0.
|
|
57
|
+
"@granite-js/plugin-core": "3.0.4",
|
|
58
58
|
"@swc/core": "1.15.46",
|
|
59
59
|
"chokidar": "4.0.1",
|
|
60
60
|
"es-toolkit": "^1.39.8"
|