@anaemia/bundler 0.1.2 → 0.1.3
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 +12 -7
- package/dist/router/manifest.d.ts +0 -9
- package/dist/router/manifest.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +13 -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,CAmJ1H;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,7 +107,7 @@ 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
|
};
|
|
@@ -110,7 +115,7 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
110
115
|
name: "server",
|
|
111
116
|
context: appRoot,
|
|
112
117
|
target: "node",
|
|
113
|
-
entry: { server: path.resolve(
|
|
118
|
+
entry: { server: path.resolve(runtimeDir, `entry-server.${runtimeExt}`) },
|
|
114
119
|
output: { path: path.resolve(appRoot, "./dist/server"), filename: "index.js", module: true, chunkFormat: "module", chunkLoading: "import" },
|
|
115
120
|
optimization: { nodeEnv: false },
|
|
116
121
|
resolve: {
|
|
@@ -119,8 +124,8 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
119
124
|
alias: {
|
|
120
125
|
...sharedResolve.alias,
|
|
121
126
|
"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"),
|
|
127
|
+
"@anaemia/core/config": hasSrc ? path.resolve(coreRuntimeDir, "./src/config.ts") : path.resolve(coreRuntimeDir, "./dist/config.js"),
|
|
128
|
+
"@anaemia/core": hasSrc ? path.resolve(coreRuntimeDir, "./src/index.ts") : path.resolve(coreRuntimeDir, "./dist/index.js"),
|
|
124
129
|
__anaemia_user_config__: path.resolve(appRoot, "./anaemia.config.ts"),
|
|
125
130
|
__anaemia_server_routes__: serverRoutesFile,
|
|
126
131
|
},
|
|
@@ -137,7 +142,7 @@ export async function getRspackConfig(appRoot, config = {}) {
|
|
|
137
142
|
{
|
|
138
143
|
...createBabelRule({ isServer: true, isDev, plugins: [...extraServerBabelPlugins] }),
|
|
139
144
|
include: /[\\/]node_modules[\\/]@solidjs[\\/]router/,
|
|
140
|
-
}
|
|
145
|
+
},
|
|
141
146
|
],
|
|
142
147
|
},
|
|
143
148
|
};
|
|
@@ -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
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,7 +122,7 @@ 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
|
};
|
|
@@ -126,7 +131,7 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
126
131
|
name: "server",
|
|
127
132
|
context: appRoot,
|
|
128
133
|
target: "node",
|
|
129
|
-
entry: { server: path.resolve(
|
|
134
|
+
entry: { server: path.resolve(runtimeDir, `entry-server.${runtimeExt}`) },
|
|
130
135
|
output: { path: path.resolve(appRoot, "./dist/server"), filename: "index.js", module: true, chunkFormat: "module", chunkLoading: "import" },
|
|
131
136
|
optimization: { nodeEnv: false },
|
|
132
137
|
resolve: {
|
|
@@ -135,8 +140,8 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
135
140
|
alias: {
|
|
136
141
|
...sharedResolve.alias,
|
|
137
142
|
"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"),
|
|
143
|
+
"@anaemia/core/config": hasSrc ? path.resolve(coreRuntimeDir, "./src/config.ts") : path.resolve(coreRuntimeDir, "./dist/config.js"),
|
|
144
|
+
"@anaemia/core": hasSrc ? path.resolve(coreRuntimeDir, "./src/index.ts") : path.resolve(coreRuntimeDir, "./dist/index.js"),
|
|
140
145
|
__anaemia_user_config__: path.resolve(appRoot, "./anaemia.config.ts"),
|
|
141
146
|
__anaemia_server_routes__: serverRoutesFile,
|
|
142
147
|
},
|
|
@@ -153,7 +158,7 @@ export async function getRspackConfig(appRoot: string, config: AnaemiaConfig = {
|
|
|
153
158
|
{
|
|
154
159
|
...createBabelRule({ isServer: true, isDev, plugins: [...extraServerBabelPlugins] }),
|
|
155
160
|
include: /[\\/]node_modules[\\/]@solidjs[\\/]router/,
|
|
156
|
-
}
|
|
161
|
+
},
|
|
157
162
|
],
|
|
158
163
|
},
|
|
159
164
|
};
|
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 }>;
|