@anaemia/bundler 0.1.2 → 0.2.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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -7
- package/dist/router/manifest.d.ts +0 -9
- package/dist/router/manifest.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/index.ts +14 -8
- package/src/router/manifest.ts +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,cAAc,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAqB1D,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,cAAc,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAqB1D,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAoJ1H;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,9 @@ const __dirname = path.dirname(__filename);
|
|
|
19
19
|
export async function getRspackConfig(appRoot, config = {}) {
|
|
20
20
|
const isDev = process.env.NODE_ENV !== "production";
|
|
21
21
|
const coreRuntimeDir = path.dirname(require.resolve("@anaemia/core/package.json"));
|
|
22
|
+
const hasSrc = fs.existsSync(path.resolve(coreRuntimeDir, "./src/runtime"));
|
|
23
|
+
const runtimeDir = hasSrc ? path.resolve(coreRuntimeDir, "./src/runtime") : path.resolve(coreRuntimeDir, "./dist/runtime");
|
|
24
|
+
const runtimeExt = hasSrc ? "tsx" : "jsx";
|
|
22
25
|
const routes = await scanRoutes(appRoot);
|
|
23
26
|
const serverRoutes = scanServerRoutes(appRoot);
|
|
24
27
|
writeManifest(appRoot, routes);
|
|
@@ -44,7 +47,7 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
44
47
|
devtool: isDev ? "eval-cheap-module-source-map" : false,
|
|
45
48
|
cache: isDev,
|
|
46
49
|
entry: {
|
|
47
|
-
client: [...(isDev ? [require.resolve("solid-refresh")] : []), path.resolve(
|
|
50
|
+
client: [...(isDev ? [require.resolve("solid-refresh")] : []), path.resolve(runtimeDir, `entry-client.${runtimeExt}`)],
|
|
48
51
|
},
|
|
49
52
|
output: {
|
|
50
53
|
path: path.resolve(appRoot, "./dist/client"),
|
|
@@ -82,7 +85,9 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
82
85
|
__ANAEMIA_RUNTIME_CONFIG__: JSON.stringify({ port: config.port, assets: config.assets, styles: config.styles }),
|
|
83
86
|
...config.define?.client,
|
|
84
87
|
}),
|
|
85
|
-
new rspack.NormalModuleReplacementPlugin(/^node:/, (resource) => {
|
|
88
|
+
new rspack.NormalModuleReplacementPlugin(/^node:/, (resource) => {
|
|
89
|
+
resource.request = resource.request.replace(/^node:/, "");
|
|
90
|
+
}),
|
|
86
91
|
new rspack.NormalModuleReplacementPlugin(/\.server\.(ts|tsx|js|jsx)$/, (() => {
|
|
87
92
|
const srcPath = path.resolve(__dirname, "./runtime/empty-module.cjs");
|
|
88
93
|
if (fs.existsSync(srcPath))
|
|
@@ -102,15 +107,16 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
102
107
|
{
|
|
103
108
|
...createBabelRule({ isServer: false, isDev, plugins: [clientServerFnTransform, ...(isDev ? [solidRefreshPlugin] : []), ...extraClientBabelPlugins] }),
|
|
104
109
|
include: /[\\/]node_modules[\\/]@solidjs[\\/]router/,
|
|
105
|
-
}
|
|
110
|
+
},
|
|
106
111
|
],
|
|
107
112
|
},
|
|
108
113
|
};
|
|
109
114
|
let serverConfig = {
|
|
110
115
|
name: "server",
|
|
116
|
+
devtool: isDev ? "source-map" : false,
|
|
111
117
|
context: appRoot,
|
|
112
118
|
target: "node",
|
|
113
|
-
entry: { server: path.resolve(
|
|
119
|
+
entry: { server: path.resolve(runtimeDir, `entry-server.${runtimeExt}`) },
|
|
114
120
|
output: { path: path.resolve(appRoot, "./dist/server"), filename: "index.js", module: true, chunkFormat: "module", chunkLoading: "import" },
|
|
115
121
|
optimization: { nodeEnv: false },
|
|
116
122
|
resolve: {
|
|
@@ -119,8 +125,8 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
119
125
|
alias: {
|
|
120
126
|
...sharedResolve.alias,
|
|
121
127
|
"solid-refresh": require.resolve("solid-refresh"),
|
|
122
|
-
"@anaemia/core/config": path.resolve(coreRuntimeDir, "./src/config.ts"),
|
|
123
|
-
"@anaemia/core": path.resolve(coreRuntimeDir, "./src/index.ts"),
|
|
128
|
+
"@anaemia/core/config": hasSrc ? path.resolve(coreRuntimeDir, "./src/config.ts") : path.resolve(coreRuntimeDir, "./dist/config.js"),
|
|
129
|
+
"@anaemia/core": hasSrc ? path.resolve(coreRuntimeDir, "./src/index.ts") : path.resolve(coreRuntimeDir, "./dist/index.js"),
|
|
124
130
|
__anaemia_user_config__: path.resolve(appRoot, "./anaemia.config.ts"),
|
|
125
131
|
__anaemia_server_routes__: serverRoutesFile,
|
|
126
132
|
},
|
|
@@ -137,7 +143,7 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
137
143
|
{
|
|
138
144
|
...createBabelRule({ isServer: true, isDev, plugins: [...extraServerBabelPlugins] }),
|
|
139
145
|
include: /[\\/]node_modules[\\/]@solidjs[\\/]router/,
|
|
140
|
-
}
|
|
146
|
+
},
|
|
141
147
|
],
|
|
142
148
|
},
|
|
143
149
|
};
|
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
import type { RouteManifestEntry } from "./scan.js";
|
|
2
|
-
export interface BuildManifest {
|
|
3
|
-
routes: RouteManifestEntry[];
|
|
4
|
-
chunks: Record<string, {
|
|
5
|
-
js: string;
|
|
6
|
-
css?: string;
|
|
7
|
-
}>;
|
|
8
|
-
errors: Record<string, string>;
|
|
9
|
-
buildTime: string;
|
|
10
|
-
}
|
|
11
2
|
export declare function writeManifest(appRoot: string, routes: RouteManifestEntry[]): void;
|
|
12
3
|
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/router/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/router/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAUpD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAI,CA6BjF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anaemia/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@anaemia/core": "^0.2.0",
|
|
14
15
|
"@babel/core": "^7.29.7",
|
|
15
16
|
"@babel/preset-typescript": "^7.29.7",
|
|
16
|
-
"@babel/types": "^7.29.7",
|
|
17
17
|
"@rspack/core": "^2.0.5",
|
|
18
18
|
"babel-loader": "^10.1.1",
|
|
19
19
|
"babel-preset-solid": "^1.9.12",
|
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
"jiti": "^2.7.0",
|
|
22
22
|
"sass": "^1.100.0",
|
|
23
23
|
"sass-loader": "^17.0.0",
|
|
24
|
-
"solid-refresh": "^0.7.8"
|
|
25
|
-
|
|
24
|
+
"solid-refresh": "^0.7.8"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/babel__core": "^7.20.5"
|
|
26
28
|
},
|
|
27
29
|
"scripts": {
|
|
28
30
|
"build": "tsc",
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,9 @@ const __dirname = path.dirname(__filename);
|
|
|
25
25
|
export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {}): Promise<[Configuration, Configuration]> {
|
|
26
26
|
const isDev = process.env.NODE_ENV !== "production";
|
|
27
27
|
const coreRuntimeDir = path.dirname(require.resolve("@anaemia/core/package.json"));
|
|
28
|
+
const hasSrc = fs.existsSync(path.resolve(coreRuntimeDir, "./src/runtime"));
|
|
29
|
+
const runtimeDir = hasSrc ? path.resolve(coreRuntimeDir, "./src/runtime") : path.resolve(coreRuntimeDir, "./dist/runtime");
|
|
30
|
+
const runtimeExt = hasSrc ? "tsx" : "jsx";
|
|
28
31
|
|
|
29
32
|
const routes = await scanRoutes(appRoot);
|
|
30
33
|
const serverRoutes = scanServerRoutes(appRoot);
|
|
@@ -56,7 +59,7 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
56
59
|
devtool: isDev ? "eval-cheap-module-source-map" : false,
|
|
57
60
|
cache: isDev,
|
|
58
61
|
entry: {
|
|
59
|
-
client: [...(isDev ? [require.resolve("solid-refresh")] : []), path.resolve(
|
|
62
|
+
client: [...(isDev ? [require.resolve("solid-refresh")] : []), path.resolve(runtimeDir, `entry-client.${runtimeExt}`)],
|
|
60
63
|
},
|
|
61
64
|
output: {
|
|
62
65
|
path: path.resolve(appRoot, "./dist/client"),
|
|
@@ -94,13 +97,15 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
94
97
|
__ANAEMIA_RUNTIME_CONFIG__: JSON.stringify({ port: config.port, assets: config.assets, styles: config.styles }),
|
|
95
98
|
...config.define?.client,
|
|
96
99
|
}),
|
|
97
|
-
new rspack.NormalModuleReplacementPlugin(/^node:/, (resource) => {
|
|
100
|
+
new rspack.NormalModuleReplacementPlugin(/^node:/, (resource) => {
|
|
101
|
+
resource.request = resource.request.replace(/^node:/, "");
|
|
102
|
+
}),
|
|
98
103
|
new rspack.NormalModuleReplacementPlugin(
|
|
99
104
|
/\.server\.(ts|tsx|js|jsx)$/,
|
|
100
105
|
(() => {
|
|
101
106
|
const srcPath = path.resolve(__dirname, "./runtime/empty-module.cjs");
|
|
102
107
|
if (fs.existsSync(srcPath)) return srcPath;
|
|
103
|
-
|
|
108
|
+
|
|
104
109
|
return path.resolve(__dirname, "../src/runtime/empty-module.cjs");
|
|
105
110
|
})()
|
|
106
111
|
),
|
|
@@ -117,16 +122,17 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
117
122
|
{
|
|
118
123
|
...createBabelRule({ isServer: false, isDev, plugins: [clientServerFnTransform, ...(isDev ? [solidRefreshPlugin] : []), ...extraClientBabelPlugins] }),
|
|
119
124
|
include: /[\\/]node_modules[\\/]@solidjs[\\/]router/,
|
|
120
|
-
}
|
|
125
|
+
},
|
|
121
126
|
],
|
|
122
127
|
},
|
|
123
128
|
};
|
|
124
129
|
|
|
125
130
|
let serverConfig: Configuration = {
|
|
126
131
|
name: "server",
|
|
132
|
+
devtool: isDev ? "source-map" : false,
|
|
127
133
|
context: appRoot,
|
|
128
134
|
target: "node",
|
|
129
|
-
entry: { server: path.resolve(
|
|
135
|
+
entry: { server: path.resolve(runtimeDir, `entry-server.${runtimeExt}`) },
|
|
130
136
|
output: { path: path.resolve(appRoot, "./dist/server"), filename: "index.js", module: true, chunkFormat: "module", chunkLoading: "import" },
|
|
131
137
|
optimization: { nodeEnv: false },
|
|
132
138
|
resolve: {
|
|
@@ -135,8 +141,8 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
135
141
|
alias: {
|
|
136
142
|
...sharedResolve.alias,
|
|
137
143
|
"solid-refresh": require.resolve("solid-refresh"),
|
|
138
|
-
"@anaemia/core/config": path.resolve(coreRuntimeDir, "./src/config.ts"),
|
|
139
|
-
"@anaemia/core": path.resolve(coreRuntimeDir, "./src/index.ts"),
|
|
144
|
+
"@anaemia/core/config": hasSrc ? path.resolve(coreRuntimeDir, "./src/config.ts") : path.resolve(coreRuntimeDir, "./dist/config.js"),
|
|
145
|
+
"@anaemia/core": hasSrc ? path.resolve(coreRuntimeDir, "./src/index.ts") : path.resolve(coreRuntimeDir, "./dist/index.js"),
|
|
140
146
|
__anaemia_user_config__: path.resolve(appRoot, "./anaemia.config.ts"),
|
|
141
147
|
__anaemia_server_routes__: serverRoutesFile,
|
|
142
148
|
},
|
|
@@ -153,7 +159,7 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
153
159
|
{
|
|
154
160
|
...createBabelRule({ isServer: true, isDev, plugins: [...extraServerBabelPlugins] }),
|
|
155
161
|
include: /[\\/]node_modules[\\/]@solidjs[\\/]router/,
|
|
156
|
-
}
|
|
162
|
+
},
|
|
157
163
|
],
|
|
158
164
|
},
|
|
159
165
|
};
|
package/src/router/manifest.ts
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import type { RouteManifestEntry } from "./scan.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface BuildManifest {
|
|
6
6
|
routes: RouteManifestEntry[];
|
|
7
7
|
// filled in after rspack build - maps chunkName to hashed filename
|
|
8
8
|
chunks: Record<string, { js: string; css?: string }>;
|