@quilted/rollup 0.0.0-preview-20231014022518
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/LICENSE.md +21 -0
- package/README.md +1 -0
- package/build/cjs/app.cjs +158 -0
- package/build/cjs/constants.cjs +13 -0
- package/build/cjs/env.cjs +135 -0
- package/build/cjs/index.cjs +16 -0
- package/build/cjs/request-router.cjs +31 -0
- package/build/cjs/shared/magic-module.cjs +32 -0
- package/build/cjs/shared/rollup.cjs +15 -0
- package/build/cjs/shared/strings.cjs +16 -0
- package/build/esm/app.mjs +151 -0
- package/build/esm/constants.mjs +7 -0
- package/build/esm/env.mjs +112 -0
- package/build/esm/index.mjs +3 -0
- package/build/esm/request-router.mjs +29 -0
- package/build/esm/shared/magic-module.mjs +30 -0
- package/build/esm/shared/rollup.mjs +13 -0
- package/build/esm/shared/strings.mjs +14 -0
- package/build/esnext/app.esnext +151 -0
- package/build/esnext/constants.esnext +7 -0
- package/build/esnext/env.esnext +112 -0
- package/build/esnext/index.esnext +3 -0
- package/build/esnext/request-router.esnext +29 -0
- package/build/esnext/shared/magic-module.esnext +30 -0
- package/build/esnext/shared/rollup.esnext +13 -0
- package/build/esnext/shared/strings.esnext +14 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/typescript/app.d.ts +163 -0
- package/build/typescript/app.d.ts.map +1 -0
- package/build/typescript/constants.d.ts +6 -0
- package/build/typescript/constants.d.ts.map +1 -0
- package/build/typescript/env.d.ts +55 -0
- package/build/typescript/env.d.ts.map +1 -0
- package/build/typescript/index.d.ts +4 -0
- package/build/typescript/index.d.ts.map +1 -0
- package/build/typescript/request-router.d.ts +15 -0
- package/build/typescript/request-router.d.ts.map +1 -0
- package/build/typescript/shared/magic-module.d.ts +19 -0
- package/build/typescript/shared/magic-module.d.ts.map +1 -0
- package/build/typescript/shared/rollup.d.ts +5 -0
- package/build/typescript/shared/rollup.d.ts.map +1 -0
- package/build/typescript/shared/strings.d.ts +2 -0
- package/build/typescript/shared/strings.d.ts.map +1 -0
- package/package.json +53 -0
- package/quilt.project.ts +5 -0
- package/source/app.ts +225 -0
- package/source/constants.ts +5 -0
- package/source/env.ts +176 -0
- package/source/index.ts +13 -0
- package/source/request-router.ts +34 -0
- package/source/shared/magic-module.ts +42 -0
- package/source/shared/rollup.ts +38 -0
- package/source/shared/strings.ts +17 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { MagicModuleEnvOptions } from './env.ts';
|
|
2
|
+
export interface AppOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The entry module for this app. This should be an absolute path, or relative
|
|
5
|
+
* path from the root directory containing your project. This entry should just be
|
|
6
|
+
* for the main `App` component in your project, which Quilt will automatically use
|
|
7
|
+
* to create browser and server-side entries for your project.
|
|
8
|
+
*
|
|
9
|
+
* If you only want to use a custom entry module for the browser build, use the
|
|
10
|
+
* `browser.entry` option instead. If you only want to use a custom entry module
|
|
11
|
+
* for the server-side build, use the `server.entry` option instead.
|
|
12
|
+
*
|
|
13
|
+
* @example './App.tsx'
|
|
14
|
+
*/
|
|
15
|
+
entry?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to include GraphQL-related code transformations.
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
graphql?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Customizes the behavior of environment variables for your application. You
|
|
24
|
+
* can further customize the environment variables provided during server-side
|
|
25
|
+
* rendering by passing `server.env`.
|
|
26
|
+
*/
|
|
27
|
+
env?: MagicModuleEnvOptions;
|
|
28
|
+
}
|
|
29
|
+
export declare function quiltApp({ env, entry }?: AppOptions): {
|
|
30
|
+
name: string;
|
|
31
|
+
options(this: import("rollup").MinimalPluginContext, originalOptions: import("rollup").InputOptions): Promise<{
|
|
32
|
+
plugins: import("rollup").InputPluginOption[];
|
|
33
|
+
cache?: boolean | import("rollup").RollupCache | undefined;
|
|
34
|
+
context?: string | undefined;
|
|
35
|
+
experimentalCacheExpiry?: number | undefined;
|
|
36
|
+
experimentalLogSideEffects?: boolean | undefined;
|
|
37
|
+
external?: import("rollup").ExternalOption | undefined;
|
|
38
|
+
input?: import("rollup").InputOption | undefined;
|
|
39
|
+
logLevel?: import("rollup").LogLevelOption | undefined;
|
|
40
|
+
makeAbsoluteExternalsRelative?: boolean | "ifRelativeSource" | undefined;
|
|
41
|
+
maxParallelFileOps?: number | undefined;
|
|
42
|
+
moduleContext?: ((id: string) => string | import("rollup").NullValue) | {
|
|
43
|
+
[id: string]: string;
|
|
44
|
+
} | undefined;
|
|
45
|
+
onLog?: import("rollup").LogHandlerWithDefault | undefined;
|
|
46
|
+
onwarn?: import("rollup").WarningHandlerWithDefault | undefined;
|
|
47
|
+
perf?: boolean | undefined;
|
|
48
|
+
preserveEntrySignatures?: import("rollup").PreserveEntrySignaturesOption | undefined;
|
|
49
|
+
preserveSymlinks?: boolean | undefined;
|
|
50
|
+
shimMissingExports?: boolean | undefined;
|
|
51
|
+
strictDeprecations?: boolean | undefined;
|
|
52
|
+
treeshake?: boolean | import("rollup").TreeshakingPreset | import("rollup").TreeshakingOptions | undefined;
|
|
53
|
+
watch?: false | import("rollup").WatcherOptions | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
export interface AppBrowserOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Whether the app should use hydration or client-side rendering.
|
|
59
|
+
*/
|
|
60
|
+
hydrate?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The CSS selector to render or hydrate the application into.
|
|
63
|
+
*/
|
|
64
|
+
selector?: string;
|
|
65
|
+
}
|
|
66
|
+
export declare function quiltAppBrowser(options?: AppBrowserOptions): {
|
|
67
|
+
name: string;
|
|
68
|
+
options(this: import("rollup").MinimalPluginContext, originalOptions: import("rollup").InputOptions): {
|
|
69
|
+
plugins: import("rollup").InputPluginOption[];
|
|
70
|
+
cache?: boolean | import("rollup").RollupCache | undefined;
|
|
71
|
+
context?: string | undefined;
|
|
72
|
+
experimentalCacheExpiry?: number | undefined;
|
|
73
|
+
experimentalLogSideEffects?: boolean | undefined;
|
|
74
|
+
external?: import("rollup").ExternalOption | undefined;
|
|
75
|
+
input?: import("rollup").InputOption | undefined;
|
|
76
|
+
logLevel?: import("rollup").LogLevelOption | undefined;
|
|
77
|
+
makeAbsoluteExternalsRelative?: boolean | "ifRelativeSource" | undefined;
|
|
78
|
+
maxParallelFileOps?: number | undefined;
|
|
79
|
+
moduleContext?: ((id: string) => string | import("rollup").NullValue) | {
|
|
80
|
+
[id: string]: string;
|
|
81
|
+
} | undefined;
|
|
82
|
+
onLog?: import("rollup").LogHandlerWithDefault | undefined;
|
|
83
|
+
onwarn?: import("rollup").WarningHandlerWithDefault | undefined;
|
|
84
|
+
perf?: boolean | undefined;
|
|
85
|
+
preserveEntrySignatures?: import("rollup").PreserveEntrySignaturesOption | undefined;
|
|
86
|
+
preserveSymlinks?: boolean | undefined;
|
|
87
|
+
shimMissingExports?: boolean | undefined;
|
|
88
|
+
strictDeprecations?: boolean | undefined;
|
|
89
|
+
treeshake?: boolean | import("rollup").TreeshakingPreset | import("rollup").TreeshakingOptions | undefined;
|
|
90
|
+
watch?: false | import("rollup").WatcherOptions | undefined;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export interface AppServerOptions {
|
|
94
|
+
/**
|
|
95
|
+
* The entry module for the server of this app. This module must export a
|
|
96
|
+
* `RequestRouter` object as its default export, which will be wrapped in
|
|
97
|
+
* the specific server runtime you configure.
|
|
98
|
+
*/
|
|
99
|
+
entry?: string;
|
|
100
|
+
}
|
|
101
|
+
export declare function quiltAppServer(options?: AppServerOptions): {
|
|
102
|
+
name: string;
|
|
103
|
+
options(this: import("rollup").MinimalPluginContext, originalOptions: import("rollup").InputOptions): Promise<{
|
|
104
|
+
plugins: import("rollup").InputPluginOption[];
|
|
105
|
+
cache?: boolean | import("rollup").RollupCache | undefined;
|
|
106
|
+
context?: string | undefined;
|
|
107
|
+
experimentalCacheExpiry?: number | undefined;
|
|
108
|
+
experimentalLogSideEffects?: boolean | undefined;
|
|
109
|
+
external?: import("rollup").ExternalOption | undefined;
|
|
110
|
+
input?: import("rollup").InputOption | undefined;
|
|
111
|
+
logLevel?: import("rollup").LogLevelOption | undefined;
|
|
112
|
+
makeAbsoluteExternalsRelative?: boolean | "ifRelativeSource" | undefined;
|
|
113
|
+
maxParallelFileOps?: number | undefined;
|
|
114
|
+
moduleContext?: ((id: string) => string | import("rollup").NullValue) | {
|
|
115
|
+
[id: string]: string;
|
|
116
|
+
} | undefined;
|
|
117
|
+
onLog?: import("rollup").LogHandlerWithDefault | undefined;
|
|
118
|
+
onwarn?: import("rollup").WarningHandlerWithDefault | undefined;
|
|
119
|
+
perf?: boolean | undefined;
|
|
120
|
+
preserveEntrySignatures?: import("rollup").PreserveEntrySignaturesOption | undefined;
|
|
121
|
+
preserveSymlinks?: boolean | undefined;
|
|
122
|
+
shimMissingExports?: boolean | undefined;
|
|
123
|
+
strictDeprecations?: boolean | undefined;
|
|
124
|
+
treeshake?: boolean | import("rollup").TreeshakingPreset | import("rollup").TreeshakingOptions | undefined;
|
|
125
|
+
watch?: false | import("rollup").WatcherOptions | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
};
|
|
128
|
+
export declare function magicModuleAppComponent({ entry }: {
|
|
129
|
+
entry: string;
|
|
130
|
+
}): {
|
|
131
|
+
name: string;
|
|
132
|
+
resolveId(this: import("rollup").PluginContext, id: string): {
|
|
133
|
+
id: string;
|
|
134
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
135
|
+
} | null;
|
|
136
|
+
load: ((this: import("rollup").PluginContext, source: string) => Promise<{
|
|
137
|
+
code: string;
|
|
138
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
139
|
+
} | null>) | undefined;
|
|
140
|
+
};
|
|
141
|
+
export declare function magicModuleAppRequestRouter({ entry, }?: Pick<AppServerOptions, 'entry'>): {
|
|
142
|
+
name: string;
|
|
143
|
+
resolveId(this: import("rollup").PluginContext, id: string): {
|
|
144
|
+
id: string;
|
|
145
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
146
|
+
} | null;
|
|
147
|
+
load: ((this: import("rollup").PluginContext, source: string) => Promise<{
|
|
148
|
+
code: string;
|
|
149
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
150
|
+
} | null>) | undefined;
|
|
151
|
+
};
|
|
152
|
+
export declare function magicModuleAppBrowserEntry({ hydrate, selector, }?: AppBrowserOptions): {
|
|
153
|
+
name: string;
|
|
154
|
+
resolveId(this: import("rollup").PluginContext, id: string): {
|
|
155
|
+
id: string;
|
|
156
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
157
|
+
} | null;
|
|
158
|
+
load: ((this: import("rollup").PluginContext, source: string) => Promise<{
|
|
159
|
+
code: string;
|
|
160
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
161
|
+
} | null>) | undefined;
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../source/app.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAKpD,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,GAAG,CAAC,EAAE,qBAAqB,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,GAAE,UAAe;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCrD;AAED,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,iBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;EAmB9D;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;EAwB5D;AAED,wBAAgB,uBAAuB,CAAC,EAAC,KAAK,EAAC,EAAE;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC;;;;;;;;;;EAM/D;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,GACN,GAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAM;;;;;;;;;;EAqCtC;AAED,wBAAgB,0BAA0B,CAAC,EACzC,OAAc,EACd,QAAiB,GAClB,GAAE,iBAAsB;;;;;;;;;;EA0BxB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const MAGIC_MODULE_ENV = "quilt:module/env";
|
|
2
|
+
export declare const MAGIC_MODULE_ENTRY = "quilt:module/entry";
|
|
3
|
+
export declare const MAGIC_MODULE_APP_COMPONENT = "quilt:module/app";
|
|
4
|
+
export declare const MAGIC_MODULE_BROWSER_ASSETS = "quilt:module/assets";
|
|
5
|
+
export declare const MAGIC_MODULE_REQUEST_ROUTER = "quilt:module/request-router";
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../source/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAC7D,eAAO,MAAM,2BAA2B,wBAAwB,CAAC;AACjE,eAAO,MAAM,2BAA2B,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PluginContext } from 'rollup';
|
|
2
|
+
export declare function replaceProcessEnv({ mode, preserve, }: {
|
|
3
|
+
mode: string;
|
|
4
|
+
preserve?: boolean;
|
|
5
|
+
}): import("rollup").Plugin<any>;
|
|
6
|
+
export interface MagicModuleEnvOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The runtime mode for your target environment.
|
|
9
|
+
*/
|
|
10
|
+
mode?: 'production' | 'development';
|
|
11
|
+
/**
|
|
12
|
+
* Environment variables from the build environment to inline into the magic
|
|
13
|
+
* module. Be careful when using this option! Inlining environment variables
|
|
14
|
+
* into your application always comes with the risk of exposing sensitive information
|
|
15
|
+
* to your users. Only use this option for environment variables that are safe
|
|
16
|
+
* for a human to see if they open their browser developer tools.
|
|
17
|
+
*/
|
|
18
|
+
inline?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* A string that will be inlined directly as code to reference a runtime variable
|
|
21
|
+
* that contains environment variables.
|
|
22
|
+
*/
|
|
23
|
+
runtime?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to load environment variables from a `.env` file. The option can
|
|
26
|
+
* be one of the following types:
|
|
27
|
+
*
|
|
28
|
+
* - `false`, which disables loading environment variables from a `.env` file.
|
|
29
|
+
* - An object containing a `roots` field, specifying the directories to search
|
|
30
|
+
* for `.env` files in.
|
|
31
|
+
* - An object containing a `files` field, specifying the directories to search
|
|
32
|
+
* for `.env` files in.
|
|
33
|
+
*
|
|
34
|
+
* @default {roots: ['.', 'configuration']}
|
|
35
|
+
*/
|
|
36
|
+
dotenv?: false | {
|
|
37
|
+
roots?: string[];
|
|
38
|
+
files?: never;
|
|
39
|
+
} | {
|
|
40
|
+
roots?: never;
|
|
41
|
+
files?: string[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export declare function magicModuleEnv({ mode, dotenv, inline, runtime, }?: MagicModuleEnvOptions): {
|
|
45
|
+
name: string;
|
|
46
|
+
resolveId(this: PluginContext, id: string): {
|
|
47
|
+
id: string;
|
|
48
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
49
|
+
} | null;
|
|
50
|
+
load: ((this: PluginContext, source: string) => Promise<{
|
|
51
|
+
code: string;
|
|
52
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
53
|
+
} | null>) | undefined;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../source/env.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAa1C,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,QAAe,GAChB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,gCAQA;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;IAEpC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EACH,KAAK,GACL;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAC,GACjC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,MAAwC,EACxC,MAAW,EACX,OAAc,GACf,GAAE,qBAA0B;;;;;;;;;;EA0C5B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { magicModuleEnv, type MagicModuleEnvOptions } from './env.ts';
|
|
2
|
+
export { quiltApp, quiltAppBrowser, quiltAppServer, magicModuleAppComponent, magicModuleAppBrowserEntry, magicModuleAppRequestRouter, type AppOptions, type AppBrowserOptions, type AppServerOptions, } from './app.ts';
|
|
3
|
+
export { magicModuleRequestRouterEntry } from './request-router.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,KAAK,qBAAqB,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,QAAQ,EACR,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC3B,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,6BAA6B,EAAC,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function magicModuleRequestRouterEntry({ host, port, }?: {
|
|
2
|
+
host?: string;
|
|
3
|
+
port?: number;
|
|
4
|
+
}): {
|
|
5
|
+
name: string;
|
|
6
|
+
resolveId(this: import("rollup").PluginContext, id: string): {
|
|
7
|
+
id: string;
|
|
8
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
9
|
+
} | null;
|
|
10
|
+
load: ((this: import("rollup").PluginContext, source: string) => Promise<{
|
|
11
|
+
code: string;
|
|
12
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
13
|
+
} | null>) | undefined;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=request-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-router.d.ts","sourceRoot":"","sources":["../../source/request-router.ts"],"names":[],"mappings":"AAKA,wBAAgB,6BAA6B,CAAC,EAC5C,IAAI,EACJ,IAAI,GACL,GAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACV;;;;;;;;;;EAsBL"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PluginContext } from 'rollup';
|
|
2
|
+
export declare function createMagicModulePlugin({ name, module, alias, source: getSource, sideEffects, }: {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly alias?: string;
|
|
5
|
+
readonly module: string;
|
|
6
|
+
readonly sideEffects?: boolean;
|
|
7
|
+
source?(this: PluginContext): string | Promise<string>;
|
|
8
|
+
}): {
|
|
9
|
+
name: string;
|
|
10
|
+
resolveId(this: PluginContext, id: string): {
|
|
11
|
+
id: string;
|
|
12
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
13
|
+
} | null;
|
|
14
|
+
load: ((this: PluginContext, source: string) => Promise<{
|
|
15
|
+
code: string;
|
|
16
|
+
moduleSideEffects: "no-treeshake" | undefined;
|
|
17
|
+
} | null>) | undefined;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=magic-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic-module.d.ts","sourceRoot":"","sources":["../../../source/shared/magic-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,aAAa,EAAC,MAAM,QAAQ,CAAC;AAKlD,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,KAAoE,EACpE,MAAM,EAAE,SAAS,EACjB,WAAmB,GACpB,EAAE;IACD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,MAAM,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACxD;;;;;;;;;;EAwBA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InputOptions } from 'rollup';
|
|
2
|
+
import { type RollupReplaceOptions } from '@rollup/plugin-replace';
|
|
3
|
+
export declare function smartReplace(values: NonNullable<RollupReplaceOptions['values']>, options?: Omit<RollupReplaceOptions, 'values'>): import("rollup").Plugin<any>;
|
|
4
|
+
export declare function addRollupOnWarn(options: InputOptions, warn: NonNullable<InputOptions['onwarn']>): InputOptions;
|
|
5
|
+
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../../source/shared/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AACzC,OAAgB,EAAC,KAAK,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE1E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,EACnD,OAAO,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,gCAY/C;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GACxC,YAAY,CAed"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../../source/shared/strings.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,UAgBxE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quilted/rollup",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"@quilted/registry": "https://registry.npmjs.org"
|
|
8
|
+
},
|
|
9
|
+
"version": "0.0.0-preview-20231014022518",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=14.0.0"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/lemonmade/quilt.git",
|
|
16
|
+
"directory": "packages/rollup"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./build/typescript/index.d.ts",
|
|
21
|
+
"quilt:source": "./source/index.ts",
|
|
22
|
+
"quilt:esnext": "./build/esnext/index.esnext",
|
|
23
|
+
"import": "./build/esm/index.mjs",
|
|
24
|
+
"require": "./build/cjs/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"types": "./build/typescript/index.d.ts",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@rollup/plugin-replace": "^5.0.0",
|
|
31
|
+
"dotenv": "^16.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"rollup": "^4.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"rollup": {
|
|
38
|
+
"optional": false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@quilted/testing": "^0.1.0",
|
|
43
|
+
"rollup": "^4.0.0"
|
|
44
|
+
},
|
|
45
|
+
"eslintConfig": {
|
|
46
|
+
"extends": [
|
|
47
|
+
"@quilted/eslint-config/project"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"browserslist": [
|
|
51
|
+
"extends @quilted/browserslist-config/defaults"
|
|
52
|
+
]
|
|
53
|
+
}
|
package/quilt.project.ts
ADDED
package/source/app.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import type {Plugin} from 'rollup';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MAGIC_MODULE_ENTRY,
|
|
5
|
+
MAGIC_MODULE_APP_COMPONENT,
|
|
6
|
+
MAGIC_MODULE_BROWSER_ASSETS,
|
|
7
|
+
MAGIC_MODULE_REQUEST_ROUTER,
|
|
8
|
+
} from './constants.ts';
|
|
9
|
+
import type {MagicModuleEnvOptions} from './env.ts';
|
|
10
|
+
|
|
11
|
+
import {multiline} from './shared/strings.ts';
|
|
12
|
+
import {createMagicModulePlugin} from './shared/magic-module.ts';
|
|
13
|
+
|
|
14
|
+
export interface AppOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The entry module for this app. This should be an absolute path, or relative
|
|
17
|
+
* path from the root directory containing your project. This entry should just be
|
|
18
|
+
* for the main `App` component in your project, which Quilt will automatically use
|
|
19
|
+
* to create browser and server-side entries for your project.
|
|
20
|
+
*
|
|
21
|
+
* If you only want to use a custom entry module for the browser build, use the
|
|
22
|
+
* `browser.entry` option instead. If you only want to use a custom entry module
|
|
23
|
+
* for the server-side build, use the `server.entry` option instead.
|
|
24
|
+
*
|
|
25
|
+
* @example './App.tsx'
|
|
26
|
+
*/
|
|
27
|
+
entry?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether to include GraphQL-related code transformations.
|
|
31
|
+
*
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
graphql?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Customizes the behavior of environment variables for your application. You
|
|
38
|
+
* can further customize the environment variables provided during server-side
|
|
39
|
+
* rendering by passing `server.env`.
|
|
40
|
+
*/
|
|
41
|
+
env?: MagicModuleEnvOptions;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function quiltApp({env, entry}: AppOptions = {}) {
|
|
45
|
+
return {
|
|
46
|
+
name: '@quilted/app',
|
|
47
|
+
async options(originalOptions) {
|
|
48
|
+
const newPlugins = [
|
|
49
|
+
...(Array.isArray(originalOptions.plugins)
|
|
50
|
+
? originalOptions.plugins
|
|
51
|
+
: originalOptions.plugins
|
|
52
|
+
? [originalOptions.plugins]
|
|
53
|
+
: []),
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const newOptions = {...originalOptions, plugins: newPlugins};
|
|
57
|
+
|
|
58
|
+
if (env) {
|
|
59
|
+
const {magicModuleEnv, replaceProcessEnv} = await import('./env.ts');
|
|
60
|
+
|
|
61
|
+
if (typeof env === 'boolean') {
|
|
62
|
+
newPlugins.push(replaceProcessEnv({mode: 'production'}));
|
|
63
|
+
newPlugins.push(magicModuleEnv({mode: 'production'}));
|
|
64
|
+
} else {
|
|
65
|
+
newPlugins.push(replaceProcessEnv({mode: env.mode ?? 'production'}));
|
|
66
|
+
newPlugins.push(magicModuleEnv({mode: 'production', ...env}));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (entry) {
|
|
71
|
+
newPlugins.push(magicModuleAppComponent({entry}));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return newOptions;
|
|
75
|
+
},
|
|
76
|
+
} satisfies Plugin;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface AppBrowserOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Whether the app should use hydration or client-side rendering.
|
|
82
|
+
*/
|
|
83
|
+
hydrate?: boolean;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The CSS selector to render or hydrate the application into.
|
|
87
|
+
*/
|
|
88
|
+
selector?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function quiltAppBrowser(options: AppBrowserOptions = {}) {
|
|
92
|
+
return {
|
|
93
|
+
name: '@quilted/app/browser',
|
|
94
|
+
options(originalOptions) {
|
|
95
|
+
const newPlugins = [
|
|
96
|
+
...(Array.isArray(originalOptions.plugins)
|
|
97
|
+
? originalOptions.plugins
|
|
98
|
+
: originalOptions.plugins
|
|
99
|
+
? [originalOptions.plugins]
|
|
100
|
+
: []),
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const newOptions = {...originalOptions, plugins: newPlugins};
|
|
104
|
+
|
|
105
|
+
newPlugins.push(magicModuleAppBrowserEntry(options));
|
|
106
|
+
|
|
107
|
+
return newOptions;
|
|
108
|
+
},
|
|
109
|
+
} satisfies Plugin;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface AppServerOptions {
|
|
113
|
+
/**
|
|
114
|
+
* The entry module for the server of this app. This module must export a
|
|
115
|
+
* `RequestRouter` object as its default export, which will be wrapped in
|
|
116
|
+
* the specific server runtime you configure.
|
|
117
|
+
*/
|
|
118
|
+
entry?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function quiltAppServer(options: AppServerOptions = {}) {
|
|
122
|
+
return {
|
|
123
|
+
name: '@quilted/app/server',
|
|
124
|
+
async options(originalOptions) {
|
|
125
|
+
const newPlugins = [
|
|
126
|
+
...(Array.isArray(originalOptions.plugins)
|
|
127
|
+
? originalOptions.plugins
|
|
128
|
+
: originalOptions.plugins
|
|
129
|
+
? [originalOptions.plugins]
|
|
130
|
+
: []),
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
const [{magicModuleRequestRouterEntry}] = await Promise.all([
|
|
134
|
+
import('./request-router.ts'),
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
const newOptions = {...originalOptions, plugins: newPlugins};
|
|
138
|
+
|
|
139
|
+
newPlugins.push(magicModuleRequestRouterEntry());
|
|
140
|
+
newPlugins.push(magicModuleAppRequestRouter(options));
|
|
141
|
+
|
|
142
|
+
return newOptions;
|
|
143
|
+
},
|
|
144
|
+
} satisfies Plugin;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function magicModuleAppComponent({entry}: {entry: string}) {
|
|
148
|
+
return createMagicModulePlugin({
|
|
149
|
+
name: '@quilted/magic-module/app',
|
|
150
|
+
module: MAGIC_MODULE_APP_COMPONENT,
|
|
151
|
+
alias: entry,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function magicModuleAppRequestRouter({
|
|
156
|
+
entry,
|
|
157
|
+
}: Pick<AppServerOptions, 'entry'> = {}) {
|
|
158
|
+
return createMagicModulePlugin({
|
|
159
|
+
name: '@quilted/magic-module/app-request-router',
|
|
160
|
+
module: MAGIC_MODULE_REQUEST_ROUTER,
|
|
161
|
+
alias: entry,
|
|
162
|
+
source: entry
|
|
163
|
+
? undefined
|
|
164
|
+
: async function source() {
|
|
165
|
+
return multiline`
|
|
166
|
+
import '@quilted/quilt/globals';
|
|
167
|
+
|
|
168
|
+
import {jsx} from 'react/jsx-runtime';
|
|
169
|
+
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
170
|
+
import {renderToResponse} from '@quilted/quilt/server';
|
|
171
|
+
|
|
172
|
+
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
173
|
+
import {BrowserAssets} from ${JSON.stringify(
|
|
174
|
+
MAGIC_MODULE_BROWSER_ASSETS,
|
|
175
|
+
)};
|
|
176
|
+
|
|
177
|
+
const router = new RequestRouter();
|
|
178
|
+
const assets = new BrowserAssets();
|
|
179
|
+
|
|
180
|
+
// For all GET requests, render our React application.
|
|
181
|
+
router.get(async (request) => {
|
|
182
|
+
const response = await renderToResponse(jsx(App), {
|
|
183
|
+
request,
|
|
184
|
+
assets,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return response;
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export default router;
|
|
191
|
+
`;
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function magicModuleAppBrowserEntry({
|
|
197
|
+
hydrate = true,
|
|
198
|
+
selector = '#app',
|
|
199
|
+
}: AppBrowserOptions = {}) {
|
|
200
|
+
return createMagicModulePlugin({
|
|
201
|
+
name: '@quilted/magic-module/app-browser-entry',
|
|
202
|
+
module: MAGIC_MODULE_ENTRY,
|
|
203
|
+
sideEffects: true,
|
|
204
|
+
async source() {
|
|
205
|
+
const reactRootFunction = hydrate ? 'hydrateRoot' : 'createRoot';
|
|
206
|
+
|
|
207
|
+
return multiline`
|
|
208
|
+
import '@quilted/quilt/globals';
|
|
209
|
+
|
|
210
|
+
import {jsx} from 'react/jsx-runtime';
|
|
211
|
+
import {${reactRootFunction}} from 'react-dom/client';
|
|
212
|
+
|
|
213
|
+
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
214
|
+
|
|
215
|
+
const element = document.querySelector(${JSON.stringify(selector)});
|
|
216
|
+
|
|
217
|
+
${
|
|
218
|
+
hydrate
|
|
219
|
+
? `${reactRootFunction}(element, jsx(App));`
|
|
220
|
+
: `${reactRootFunction}(element).render(jsx(App));`
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const MAGIC_MODULE_ENV = 'quilt:module/env';
|
|
2
|
+
export const MAGIC_MODULE_ENTRY = 'quilt:module/entry';
|
|
3
|
+
export const MAGIC_MODULE_APP_COMPONENT = 'quilt:module/app';
|
|
4
|
+
export const MAGIC_MODULE_BROWSER_ASSETS = 'quilt:module/assets';
|
|
5
|
+
export const MAGIC_MODULE_REQUEST_ROUTER = 'quilt:module/request-router';
|