@mapl/web 0.3.6 → 0.3.8
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/build/rolldown.d.ts +18 -21
- package/build/rolldown.js +12 -10
- package/build/utils.d.ts +1 -0
- package/build/utils.js +1 -0
- package/package.json +11 -9
package/build/rolldown.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { type BuildOptions, type OutputOptions, type RolldownWatcher } from "rolldown";
|
|
2
|
-
export interface MaplBuildOptions {
|
|
1
|
+
import { type BuildOptions, type OutputOptions, type RolldownWatcher, type RolldownPluginOption, type ExternalOption } from "rolldown";
|
|
2
|
+
export interface MaplBuildOptions extends Omit<BuildOptions, "input" | "output"> {
|
|
3
|
+
output?: Omit<OutputOptions, "file" | "dir">;
|
|
4
|
+
}
|
|
5
|
+
export interface MaplOptions {
|
|
3
6
|
/**
|
|
4
7
|
* App entry point
|
|
5
8
|
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Output options
|
|
9
|
-
*/
|
|
10
|
-
output: Omit<OutputOptions, "file"> & {
|
|
11
|
-
dir: string
|
|
12
|
-
};
|
|
9
|
+
main: string;
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
11
|
+
* Output directory
|
|
15
12
|
*/
|
|
16
|
-
|
|
13
|
+
outputDir: string;
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
15
|
+
* Build options
|
|
19
16
|
*/
|
|
20
|
-
|
|
17
|
+
build?: MaplBuildOptions;
|
|
21
18
|
/**
|
|
22
19
|
* Whether to emit asynchronous output
|
|
23
20
|
*/
|
|
@@ -26,13 +23,13 @@ export interface MaplBuildOptions {
|
|
|
26
23
|
* Build target
|
|
27
24
|
*/
|
|
28
25
|
target?: "bun";
|
|
26
|
+
/**
|
|
27
|
+
* Hydrate specific options
|
|
28
|
+
*/
|
|
29
|
+
hydrate?: MaplBuildOptions;
|
|
29
30
|
}
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
dev?: Partial<MaplDevOptions>;
|
|
34
|
-
build?: Partial<MaplBuildOptions>;
|
|
35
|
-
}
|
|
36
|
-
declare const _default: (opts: MaplBuildOptions) => Promise<void>;
|
|
31
|
+
export declare const hydrateImportsPlugin: RolldownPluginOption;
|
|
32
|
+
export declare const loadExternals: (currentExternals: ExternalOption | undefined) => ExternalOption;
|
|
33
|
+
declare const _default: (options: MaplOptions) => Promise<void>;
|
|
37
34
|
export default _default;
|
|
38
|
-
export declare const dev: (
|
|
35
|
+
export declare const dev: (options: MaplOptions) => RolldownWatcher;
|
package/build/rolldown.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import{mkdirSync,writeFileSync}from"node:fs";import{build,watch}from"rolldown";import{compileToExportedDependency as generic}from"../compiler/jit.js";import{compileToExportedDependency as bun}from"../compiler/bun/jit.js";import{evaluateToString}from"runtime-compiler/jit";import{clear}from"runtime-compiler";import{resolve}from"node:path";let
|
|
2
|
-
import 'runtime-compiler/hydrate-loader';
|
|
3
|
-
|
|
1
|
+
import{mkdirSync,writeFileSync}from"node:fs";import{build,watch}from"rolldown";import{compileToExportedDependency as generic}from"../compiler/jit.js";import{compileToExportedDependency as bun}from"../compiler/bun/jit.js";import{evaluateToString}from"runtime-compiler/jit";import{clear}from"runtime-compiler";import{resolve}from"node:path";import{EXTERNALS}from"./utils.js";export let hydrateImportsPlugin={name:`mapl-web-hydrate-config-replacer`,resolveId(source){return this.resolve(source===`runtime-compiler/config`?`runtime-compiler/hydrate-config`:source)}};export let loadExternals=currentExternals=>currentExternals==null?EXTERNALS:typeof currentExternals===`function`?(id,...args)=>EXTERNALS.includes(id)||currentExternals(id,...args):EXTERNALS.concat(currentExternals);export default async options=>{let buildOptions=options.build;let hydrateOptions=options.hydrate;let targetOption=options.target;let asyncOption=options.asynchronous;let outputOptions=buildOptions?.output;let inputFile=resolve(options.main);let outputFile=resolve(options.outputDir,`server-exports.js`);let tmpFile=resolve(options.outputDir,`tmp.js`);await build({...buildOptions,input:inputFile,output:{...outputOptions,file:tmpFile},treeshake:false,external:loadExternals(buildOptions?.external)});let appMod=await import(tmpFile);let HANDLER=(targetOption===`bun`?bun:generic)(appMod.default);writeFileSync(outputFile,`
|
|
4
2
|
import app from ${JSON.stringify(tmpFile)};
|
|
5
|
-
import hydrateRouter from '@mapl/web/compiler/${
|
|
3
|
+
import hydrateRouter from '@mapl/web/compiler/${targetOption===`bun`?`bun/`:``}aot';
|
|
6
4
|
hydrateRouter(app);
|
|
7
5
|
|
|
8
6
|
import { hydrate } from 'runtime-compiler/hydrate';
|
|
9
7
|
import { getDependency } from 'runtime-compiler';
|
|
10
8
|
|
|
11
|
-
${
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
${asyncOption?`await(async`:`(`}${evaluateToString()})(...hydrate());
|
|
10
|
+
export default {
|
|
11
|
+
${targetOption===`bun`?`routes`:`fetch`}: getDependency(${HANDLER})
|
|
12
|
+
};
|
|
13
|
+
`);clear();let currentPlugins=hydrateOptions?.plugins;await build({...hydrateOptions,input:outputFile,output:{...hydrateOptions?.output,file:outputFile},plugins:!currentPlugins?hydrateImportsPlugin:Array.isArray(currentPlugins)?[hydrateImportsPlugin].concat(currentPlugins):[hydrateImportsPlugin,currentPlugins]})};export let dev=options=>{let buildOptions=options.build;let targetOption=options.target;let asyncOption=options.asynchronous;let outputOptions=buildOptions?.output;let inputFile=resolve(options.main);let outputFile=resolve(options.outputDir,`server-exports.js`);let tmpFile=resolve(options.outputDir,`tmp.js`);try{mkdirSync(options.outputDir,{recursive:true})}catch{}writeFileSync(tmpFile,`
|
|
14
14
|
import app from ${JSON.stringify(inputFile)};
|
|
15
|
-
import {
|
|
15
|
+
import { ${asyncOption?`compileToHandler`:`compileToHandlerSync`} } from '@mapl/web/compiler/${targetOption===`bun`?`bun/`:``}jit';
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
export default {
|
|
18
|
+
${targetOption===`bun`?`routes`:`fetch`}: ${asyncOption?`await compileToHandler`:`compileToHandlerSync`}(app)
|
|
19
|
+
};
|
|
20
|
+
`);return watch({input:tmpFile,output:{...outputOptions,file:outputFile},treeshake:false,external:loadExternals(buildOptions?.external)})};
|
package/build/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXTERNALS: string[];
|
package/build/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export let EXTERNALS=[`runtime-compiler`,`runtime-compiler/config`,`@mapl/framework`,`@mapl/web`];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapl/web",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "A compiled web framework for all runtimes",
|
|
5
5
|
"keywords": ["fast", "lightweight", "cross-runtime", "framework", "web", "backend"],
|
|
6
6
|
"repository": {
|
|
@@ -14,24 +14,26 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@mapl/framework": "^0.5.3",
|
|
16
16
|
"@mapl/router": "^0.6.2",
|
|
17
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
17
18
|
"@safe-std/error": "^1.0.1",
|
|
18
|
-
"runtime-compiler": "^1.2.
|
|
19
|
+
"runtime-compiler": "^1.2.6"
|
|
19
20
|
},
|
|
20
21
|
"exports": {
|
|
21
|
-
"./core/context": "./core/context.js",
|
|
22
22
|
"./constants": "./constants.js",
|
|
23
23
|
"./core/middleware": "./core/middleware.js",
|
|
24
|
-
"
|
|
24
|
+
".": "./index.js",
|
|
25
25
|
"./core": "./core/index.js",
|
|
26
|
+
"./core/context": "./core/context.js",
|
|
26
27
|
"./core/handler": "./core/handler.js",
|
|
27
|
-
"./
|
|
28
|
+
"./utils/cors": "./utils/cors.js",
|
|
28
29
|
"./utils/static-headers": "./utils/static-headers.js",
|
|
29
|
-
"./compiler/aot": "./compiler/aot.js",
|
|
30
30
|
"./core/utils": "./core/utils.js",
|
|
31
|
-
"
|
|
32
|
-
"./
|
|
31
|
+
"./build/utils": "./build/utils.js",
|
|
32
|
+
"./compiler/jit": "./compiler/jit.js",
|
|
33
|
+
"./compiler/bun/jit": "./compiler/bun/jit.js",
|
|
33
34
|
"./compiler/bun/router": "./compiler/bun/router.js",
|
|
34
35
|
"./compiler/bun/aot": "./compiler/bun/aot.js",
|
|
35
|
-
"./compiler/
|
|
36
|
+
"./compiler/aot": "./compiler/aot.js",
|
|
37
|
+
"./build/rolldown": "./build/rolldown.js"
|
|
36
38
|
}
|
|
37
39
|
}
|