@quilted/rollup 0.1.0 → 0.1.2
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 +15 -0
- package/build/cjs/app.cjs +85 -15
- package/build/cjs/env.cjs +21 -16
- package/build/cjs/request-router.cjs +2 -1
- package/build/cjs/shared/magic-module.cjs +0 -12
- package/build/cjs/shared/rollup.cjs +37 -0
- package/build/esm/app.mjs +65 -14
- package/build/esm/env.mjs +21 -17
- package/build/esm/request-router.mjs +4 -3
- package/build/esm/shared/magic-module.mjs +1 -12
- package/build/esm/shared/rollup.mjs +33 -0
- package/build/esnext/app.esnext +65 -14
- package/build/esnext/env.esnext +21 -17
- package/build/esnext/request-router.esnext +4 -3
- package/build/esnext/shared/magic-module.esnext +1 -12
- package/build/esnext/shared/rollup.esnext +33 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +32 -10
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/env.d.ts +4 -0
- package/build/typescript/env.d.ts.map +1 -1
- package/build/typescript/request-router.d.ts.map +1 -1
- package/build/typescript/shared/magic-module.d.ts +0 -13
- package/build/typescript/shared/magic-module.d.ts.map +1 -1
- package/build/typescript/shared/rollup.d.ts +7 -0
- package/build/typescript/shared/rollup.d.ts.map +1 -0
- package/package.json +10 -2
- package/source/app.ts +85 -41
- package/source/env.ts +25 -2
- package/source/request-router.ts +4 -3
- package/source/shared/magic-module.ts +0 -11
- package/source/shared/rollup.ts +68 -0
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.cjs +0 -168
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.cjs +0 -10
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.cjs +0 -48
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.cjs +0 -7
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.cjs +0 -7
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.cjs +0 -23
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.cjs +0 -22
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.cjs +0 -22
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.cjs +0 -10
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.cjs +0 -20
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.cjs +0 -11
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.cjs +0 -37
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.cjs +0 -7
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.cjs +0 -33
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.mjs +0 -164
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.mjs +0 -8
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.mjs +0 -44
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.mjs +0 -5
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.mjs +0 -5
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.mjs +0 -19
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.mjs +0 -18
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.mjs +0 -18
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.mjs +0 -8
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.mjs +0 -16
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs +0 -7
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.mjs +0 -33
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs +0 -5
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.mjs +0 -29
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.esnext +0 -164
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.esnext +0 -8
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.esnext +0 -44
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.esnext +0 -5
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.esnext +0 -5
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.esnext +0 -19
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.esnext +0 -18
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.esnext +0 -18
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.esnext +0 -8
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.esnext +0 -16
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext +0 -7
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.esnext +0 -33
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext +0 -5
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.esnext +0 -29
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @quilted/rollup
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`27496819`](https://github.com/lemonmade/quilt/commit/274968195084a07507f67622c441aaabc2c429e7) Thanks [@lemonmade](https://github.com/lemonmade)! - Add Node plugins
|
|
8
|
+
|
|
9
|
+
- [`b481f939`](https://github.com/lemonmade/quilt/commit/b481f9399548b61096caf093d77658b9c9d2a789) Thanks [@lemonmade](https://github.com/lemonmade)! - Add visualizer and minify plugin
|
|
10
|
+
|
|
11
|
+
## 0.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`513f349a`](https://github.com/lemonmade/quilt/commit/513f349a4415af3fd4f6848532ea32a59385512c) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix initial rollup plugins
|
package/build/cjs/app.cjs
CHANGED
|
@@ -1,25 +1,63 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var path = require('node:path');
|
|
3
4
|
var constants = require('./constants.cjs');
|
|
4
|
-
var env = require('./env.cjs');
|
|
5
|
-
var requestRouter = require('./request-router.cjs');
|
|
6
5
|
var strings = require('./shared/strings.cjs');
|
|
6
|
+
var rollup = require('./shared/rollup.cjs');
|
|
7
7
|
var magicModule = require('./shared/magic-module.cjs');
|
|
8
8
|
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
27
|
+
|
|
9
28
|
function quiltApp({
|
|
10
|
-
env
|
|
29
|
+
env,
|
|
11
30
|
entry
|
|
12
31
|
} = {}) {
|
|
13
32
|
return {
|
|
14
33
|
name: '@quilted/app',
|
|
15
|
-
options(originalOptions) {
|
|
16
|
-
const newPlugins =
|
|
34
|
+
async options(originalOptions) {
|
|
35
|
+
const newPlugins = rollup.rollupPluginsToArray(originalOptions.plugins);
|
|
17
36
|
const newOptions = {
|
|
18
37
|
...originalOptions,
|
|
19
38
|
plugins: newPlugins
|
|
20
39
|
};
|
|
21
|
-
if (env
|
|
22
|
-
|
|
40
|
+
if (env) {
|
|
41
|
+
const {
|
|
42
|
+
magicModuleEnv,
|
|
43
|
+
replaceProcessEnv
|
|
44
|
+
} = await Promise.resolve().then(function () { return require('./env.cjs'); });
|
|
45
|
+
if (typeof env === 'boolean') {
|
|
46
|
+
newPlugins.push(replaceProcessEnv({
|
|
47
|
+
mode: 'production'
|
|
48
|
+
}));
|
|
49
|
+
newPlugins.push(magicModuleEnv({
|
|
50
|
+
mode: 'production'
|
|
51
|
+
}));
|
|
52
|
+
} else {
|
|
53
|
+
newPlugins.push(replaceProcessEnv({
|
|
54
|
+
mode: env.mode ?? 'production'
|
|
55
|
+
}));
|
|
56
|
+
newPlugins.push(magicModuleEnv({
|
|
57
|
+
mode: 'production',
|
|
58
|
+
...env
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
23
61
|
}
|
|
24
62
|
if (entry) {
|
|
25
63
|
newPlugins.push(magicModuleAppComponent({
|
|
@@ -30,16 +68,44 @@ function quiltApp({
|
|
|
30
68
|
}
|
|
31
69
|
};
|
|
32
70
|
}
|
|
33
|
-
function quiltAppBrowser(
|
|
71
|
+
function quiltAppBrowser({
|
|
72
|
+
entry,
|
|
73
|
+
env,
|
|
74
|
+
graphql,
|
|
75
|
+
assets,
|
|
76
|
+
module
|
|
77
|
+
} = {}) {
|
|
34
78
|
return {
|
|
35
79
|
name: '@quilted/app/browser',
|
|
36
|
-
options(originalOptions) {
|
|
37
|
-
const newPlugins =
|
|
80
|
+
async options(originalOptions) {
|
|
81
|
+
const newPlugins = rollup.rollupPluginsToArray(originalOptions.plugins);
|
|
38
82
|
const newOptions = {
|
|
39
83
|
...originalOptions,
|
|
40
84
|
plugins: newPlugins
|
|
41
85
|
};
|
|
42
|
-
|
|
86
|
+
const [{
|
|
87
|
+
visualizer
|
|
88
|
+
}, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), rollup.getNodePlugins()]);
|
|
89
|
+
newPlugins.push(quiltApp({
|
|
90
|
+
env,
|
|
91
|
+
entry,
|
|
92
|
+
graphql
|
|
93
|
+
}));
|
|
94
|
+
newPlugins.push(...nodePlugins);
|
|
95
|
+
newPlugins.push(magicModuleAppBrowserEntry(module));
|
|
96
|
+
const minify = assets?.minify ?? true;
|
|
97
|
+
if (minify) {
|
|
98
|
+
const {
|
|
99
|
+
minify
|
|
100
|
+
} = await import('rollup-plugin-esbuild');
|
|
101
|
+
newPlugins.push(minify());
|
|
102
|
+
}
|
|
103
|
+
newPlugins.push(visualizer({
|
|
104
|
+
template: 'treemap',
|
|
105
|
+
open: false,
|
|
106
|
+
brotliSize: true,
|
|
107
|
+
filename: path__namespace.resolve('reports', `bundle-visualizer.html`)
|
|
108
|
+
}));
|
|
43
109
|
return newOptions;
|
|
44
110
|
}
|
|
45
111
|
};
|
|
@@ -47,13 +113,16 @@ function quiltAppBrowser(options = {}) {
|
|
|
47
113
|
function quiltAppServer(options = {}) {
|
|
48
114
|
return {
|
|
49
115
|
name: '@quilted/app/server',
|
|
50
|
-
options(originalOptions) {
|
|
51
|
-
const newPlugins =
|
|
116
|
+
async options(originalOptions) {
|
|
117
|
+
const newPlugins = rollup.rollupPluginsToArray(originalOptions.plugins);
|
|
52
118
|
const newOptions = {
|
|
53
119
|
...originalOptions,
|
|
54
120
|
plugins: newPlugins
|
|
55
121
|
};
|
|
56
|
-
|
|
122
|
+
const [{
|
|
123
|
+
magicModuleRequestRouterEntry
|
|
124
|
+
}] = await Promise.all([Promise.resolve().then(function () { return require('./request-router.cjs'); })]);
|
|
125
|
+
newPlugins.push(magicModuleRequestRouterEntry());
|
|
57
126
|
newPlugins.push(magicModuleAppRequestRouter(options));
|
|
58
127
|
return newOptions;
|
|
59
128
|
}
|
|
@@ -108,8 +177,9 @@ function magicModuleAppBrowserEntry({
|
|
|
108
177
|
hydrate = true,
|
|
109
178
|
selector = '#app'
|
|
110
179
|
} = {}) {
|
|
111
|
-
return magicModule.
|
|
180
|
+
return magicModule.createMagicModulePlugin({
|
|
112
181
|
name: '@quilted/magic-module/app-browser-entry',
|
|
182
|
+
module: constants.MAGIC_MODULE_ENTRY,
|
|
113
183
|
sideEffects: true,
|
|
114
184
|
async source() {
|
|
115
185
|
const reactRootFunction = hydrate ? 'hydrateRoot' : 'createRoot';
|
package/build/cjs/env.cjs
CHANGED
|
@@ -2,22 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
4
|
var fs = require('node:fs');
|
|
5
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.cjs');
|
|
6
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.cjs');
|
|
7
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.cjs');
|
|
8
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.cjs');
|
|
9
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.cjs');
|
|
10
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.cjs');
|
|
11
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.cjs');
|
|
12
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.cjs');
|
|
13
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.cjs');
|
|
14
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.cjs');
|
|
15
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.cjs');
|
|
16
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.cjs');
|
|
17
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.cjs');
|
|
18
|
-
var stripIndent = require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.cjs');
|
|
19
|
-
require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.cjs');
|
|
20
5
|
var constants = require('./constants.cjs');
|
|
6
|
+
var strings = require('./shared/strings.cjs');
|
|
7
|
+
var rollup = require('./shared/rollup.cjs');
|
|
21
8
|
var magicModule = require('./shared/magic-module.cjs');
|
|
22
9
|
|
|
23
10
|
function _interopNamespaceDefault(e) {
|
|
@@ -40,6 +27,23 @@ function _interopNamespaceDefault(e) {
|
|
|
40
27
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
41
28
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
42
29
|
|
|
30
|
+
const EMPTY_PROCESS_ENV_OBJECT = {
|
|
31
|
+
'globalThis.process.env.': `({}).`,
|
|
32
|
+
'global.process.env.': `({}).`,
|
|
33
|
+
'process.env.': `({}).`
|
|
34
|
+
};
|
|
35
|
+
function replaceProcessEnv({
|
|
36
|
+
mode,
|
|
37
|
+
preserve = true
|
|
38
|
+
}) {
|
|
39
|
+
return rollup.smartReplace({
|
|
40
|
+
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L112
|
|
41
|
+
'globalThis.process.env.NODE_ENV': JSON.stringify(mode),
|
|
42
|
+
'global.process.env.NODE_ENV': JSON.stringify(mode),
|
|
43
|
+
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
44
|
+
...(preserve ? {} : EMPTY_PROCESS_ENV_OBJECT)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
43
47
|
function magicModuleEnv({
|
|
44
48
|
mode,
|
|
45
49
|
dotenv = {
|
|
@@ -66,7 +70,7 @@ function magicModuleEnv({
|
|
|
66
70
|
if (value == null) continue;
|
|
67
71
|
inlineEnv[inlineVariable] = typeof value === 'string' && value[0] === '"' && value[value.length - 1] === '"' ? JSON.parse(value) : value;
|
|
68
72
|
}
|
|
69
|
-
return
|
|
73
|
+
return strings.multiline`
|
|
70
74
|
const runtime = (${runtime});
|
|
71
75
|
const inline = JSON.parse(${JSON.stringify(JSON.stringify(inlineEnv))});
|
|
72
76
|
|
|
@@ -128,3 +132,4 @@ async function loadEnv({
|
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
exports.magicModuleEnv = magicModuleEnv;
|
|
135
|
+
exports.replaceProcessEnv = replaceProcessEnv;
|
|
@@ -8,9 +8,10 @@ function magicModuleRequestRouterEntry({
|
|
|
8
8
|
host,
|
|
9
9
|
port
|
|
10
10
|
} = {}) {
|
|
11
|
-
return magicModule.
|
|
11
|
+
return magicModule.createMagicModulePlugin({
|
|
12
12
|
name: '@quilted/request-router',
|
|
13
13
|
sideEffects: true,
|
|
14
|
+
module: constants.MAGIC_MODULE_ENTRY,
|
|
14
15
|
async source() {
|
|
15
16
|
const initialContent = strings.multiline`
|
|
16
17
|
import requestRouter from ${JSON.stringify(constants.MAGIC_MODULE_REQUEST_ROUTER)};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var constants = require('../constants.cjs');
|
|
4
|
-
|
|
5
3
|
const VIRTUAL_MODULE_PREFIX = '\0';
|
|
6
4
|
const VIRTUAL_MODULE_POSTFIX = '/module.js';
|
|
7
5
|
function createMagicModulePlugin({
|
|
@@ -30,15 +28,5 @@ function createMagicModulePlugin({
|
|
|
30
28
|
} : undefined
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
|
-
function createMagicModuleEntryPlugin({
|
|
34
|
-
module = constants.MAGIC_MODULE_ENTRY,
|
|
35
|
-
...options
|
|
36
|
-
}) {
|
|
37
|
-
return createMagicModulePlugin({
|
|
38
|
-
...options,
|
|
39
|
-
module
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
31
|
|
|
43
|
-
exports.createMagicModuleEntryPlugin = createMagicModuleEntryPlugin;
|
|
44
32
|
exports.createMagicModulePlugin = createMagicModulePlugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var replace = require('@rollup/plugin-replace');
|
|
4
|
+
|
|
5
|
+
function smartReplace(values, options) {
|
|
6
|
+
return replace({
|
|
7
|
+
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L108-L119
|
|
8
|
+
delimiters: ['(?<![\\p{L}\\p{N}_$]|(?<!\\.\\.)\\.)(', ')(?:(?<=\\.)|(?![\\p{L}\\p{N}_$]|\\s*?=[^=]))'],
|
|
9
|
+
preventAssignment: true,
|
|
10
|
+
...options,
|
|
11
|
+
values
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function getNodePlugins() {
|
|
15
|
+
const [{
|
|
16
|
+
default: commonjs
|
|
17
|
+
}, {
|
|
18
|
+
default: json
|
|
19
|
+
}, {
|
|
20
|
+
default: nodeResolve
|
|
21
|
+
}, {
|
|
22
|
+
default: nodeExternals
|
|
23
|
+
}] = await Promise.all([import('@rollup/plugin-commonjs'), import('@rollup/plugin-json'), import('@rollup/plugin-node-resolve'), import('rollup-plugin-node-externals')]);
|
|
24
|
+
return [nodeExternals({}), nodeResolve({
|
|
25
|
+
preferBuiltins: true,
|
|
26
|
+
dedupe: []
|
|
27
|
+
// extensions,
|
|
28
|
+
// exportConditions,
|
|
29
|
+
}), commonjs(), json()];
|
|
30
|
+
}
|
|
31
|
+
function rollupPluginsToArray(plugins) {
|
|
32
|
+
return Array.isArray(plugins) ? [...plugins] : plugins ? [plugins] : [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.getNodePlugins = getNodePlugins;
|
|
36
|
+
exports.rollupPluginsToArray = rollupPluginsToArray;
|
|
37
|
+
exports.smartReplace = smartReplace;
|
package/build/esm/app.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { magicModuleRequestRouterEntry } from './request-router.mjs';
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY } from './constants.mjs';
|
|
4
3
|
import { multiline } from './shared/strings.mjs';
|
|
5
|
-
import {
|
|
4
|
+
import { rollupPluginsToArray, getNodePlugins } from './shared/rollup.mjs';
|
|
5
|
+
import { createMagicModulePlugin } from './shared/magic-module.mjs';
|
|
6
6
|
|
|
7
7
|
function quiltApp({
|
|
8
8
|
env,
|
|
@@ -10,14 +10,33 @@ function quiltApp({
|
|
|
10
10
|
} = {}) {
|
|
11
11
|
return {
|
|
12
12
|
name: '@quilted/app',
|
|
13
|
-
options(originalOptions) {
|
|
14
|
-
const newPlugins =
|
|
13
|
+
async options(originalOptions) {
|
|
14
|
+
const newPlugins = rollupPluginsToArray(originalOptions.plugins);
|
|
15
15
|
const newOptions = {
|
|
16
16
|
...originalOptions,
|
|
17
17
|
plugins: newPlugins
|
|
18
18
|
};
|
|
19
19
|
if (env) {
|
|
20
|
-
|
|
20
|
+
const {
|
|
21
|
+
magicModuleEnv,
|
|
22
|
+
replaceProcessEnv
|
|
23
|
+
} = await import('./env.mjs');
|
|
24
|
+
if (typeof env === 'boolean') {
|
|
25
|
+
newPlugins.push(replaceProcessEnv({
|
|
26
|
+
mode: 'production'
|
|
27
|
+
}));
|
|
28
|
+
newPlugins.push(magicModuleEnv({
|
|
29
|
+
mode: 'production'
|
|
30
|
+
}));
|
|
31
|
+
} else {
|
|
32
|
+
newPlugins.push(replaceProcessEnv({
|
|
33
|
+
mode: env.mode ?? 'production'
|
|
34
|
+
}));
|
|
35
|
+
newPlugins.push(magicModuleEnv({
|
|
36
|
+
mode: 'production',
|
|
37
|
+
...env
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
21
40
|
}
|
|
22
41
|
if (entry) {
|
|
23
42
|
newPlugins.push(magicModuleAppComponent({
|
|
@@ -28,16 +47,44 @@ function quiltApp({
|
|
|
28
47
|
}
|
|
29
48
|
};
|
|
30
49
|
}
|
|
31
|
-
function quiltAppBrowser(
|
|
50
|
+
function quiltAppBrowser({
|
|
51
|
+
entry,
|
|
52
|
+
env,
|
|
53
|
+
graphql,
|
|
54
|
+
assets,
|
|
55
|
+
module
|
|
56
|
+
} = {}) {
|
|
32
57
|
return {
|
|
33
58
|
name: '@quilted/app/browser',
|
|
34
|
-
options(originalOptions) {
|
|
35
|
-
const newPlugins =
|
|
59
|
+
async options(originalOptions) {
|
|
60
|
+
const newPlugins = rollupPluginsToArray(originalOptions.plugins);
|
|
36
61
|
const newOptions = {
|
|
37
62
|
...originalOptions,
|
|
38
63
|
plugins: newPlugins
|
|
39
64
|
};
|
|
40
|
-
|
|
65
|
+
const [{
|
|
66
|
+
visualizer
|
|
67
|
+
}, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), getNodePlugins()]);
|
|
68
|
+
newPlugins.push(quiltApp({
|
|
69
|
+
env,
|
|
70
|
+
entry,
|
|
71
|
+
graphql
|
|
72
|
+
}));
|
|
73
|
+
newPlugins.push(...nodePlugins);
|
|
74
|
+
newPlugins.push(magicModuleAppBrowserEntry(module));
|
|
75
|
+
const minify = assets?.minify ?? true;
|
|
76
|
+
if (minify) {
|
|
77
|
+
const {
|
|
78
|
+
minify
|
|
79
|
+
} = await import('rollup-plugin-esbuild');
|
|
80
|
+
newPlugins.push(minify());
|
|
81
|
+
}
|
|
82
|
+
newPlugins.push(visualizer({
|
|
83
|
+
template: 'treemap',
|
|
84
|
+
open: false,
|
|
85
|
+
brotliSize: true,
|
|
86
|
+
filename: path.resolve('reports', `bundle-visualizer.html`)
|
|
87
|
+
}));
|
|
41
88
|
return newOptions;
|
|
42
89
|
}
|
|
43
90
|
};
|
|
@@ -45,12 +92,15 @@ function quiltAppBrowser(options = {}) {
|
|
|
45
92
|
function quiltAppServer(options = {}) {
|
|
46
93
|
return {
|
|
47
94
|
name: '@quilted/app/server',
|
|
48
|
-
options(originalOptions) {
|
|
49
|
-
const newPlugins =
|
|
95
|
+
async options(originalOptions) {
|
|
96
|
+
const newPlugins = rollupPluginsToArray(originalOptions.plugins);
|
|
50
97
|
const newOptions = {
|
|
51
98
|
...originalOptions,
|
|
52
99
|
plugins: newPlugins
|
|
53
100
|
};
|
|
101
|
+
const [{
|
|
102
|
+
magicModuleRequestRouterEntry
|
|
103
|
+
}] = await Promise.all([import('./request-router.mjs')]);
|
|
54
104
|
newPlugins.push(magicModuleRequestRouterEntry());
|
|
55
105
|
newPlugins.push(magicModuleAppRequestRouter(options));
|
|
56
106
|
return newOptions;
|
|
@@ -106,8 +156,9 @@ function magicModuleAppBrowserEntry({
|
|
|
106
156
|
hydrate = true,
|
|
107
157
|
selector = '#app'
|
|
108
158
|
} = {}) {
|
|
109
|
-
return
|
|
159
|
+
return createMagicModulePlugin({
|
|
110
160
|
name: '@quilted/magic-module/app-browser-entry',
|
|
161
|
+
module: MAGIC_MODULE_ENTRY,
|
|
111
162
|
sideEffects: true,
|
|
112
163
|
async source() {
|
|
113
164
|
const reactRootFunction = hydrate ? 'hydrateRoot' : 'createRoot';
|
package/build/esm/env.mjs
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.mjs';
|
|
4
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.mjs';
|
|
5
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.mjs';
|
|
6
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.mjs';
|
|
7
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.mjs';
|
|
8
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.mjs';
|
|
9
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.mjs';
|
|
10
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.mjs';
|
|
11
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.mjs';
|
|
12
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.mjs';
|
|
13
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.mjs';
|
|
14
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.mjs';
|
|
15
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.mjs';
|
|
16
|
-
import stripIndent from './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs';
|
|
17
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs';
|
|
18
3
|
import { MAGIC_MODULE_ENV } from './constants.mjs';
|
|
4
|
+
import { multiline } from './shared/strings.mjs';
|
|
5
|
+
import { smartReplace } from './shared/rollup.mjs';
|
|
19
6
|
import { createMagicModulePlugin } from './shared/magic-module.mjs';
|
|
20
7
|
|
|
8
|
+
const EMPTY_PROCESS_ENV_OBJECT = {
|
|
9
|
+
'globalThis.process.env.': `({}).`,
|
|
10
|
+
'global.process.env.': `({}).`,
|
|
11
|
+
'process.env.': `({}).`
|
|
12
|
+
};
|
|
13
|
+
function replaceProcessEnv({
|
|
14
|
+
mode,
|
|
15
|
+
preserve = true
|
|
16
|
+
}) {
|
|
17
|
+
return smartReplace({
|
|
18
|
+
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L112
|
|
19
|
+
'globalThis.process.env.NODE_ENV': JSON.stringify(mode),
|
|
20
|
+
'global.process.env.NODE_ENV': JSON.stringify(mode),
|
|
21
|
+
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
22
|
+
...(preserve ? {} : EMPTY_PROCESS_ENV_OBJECT)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
21
25
|
function magicModuleEnv({
|
|
22
26
|
mode,
|
|
23
27
|
dotenv = {
|
|
@@ -44,7 +48,7 @@ function magicModuleEnv({
|
|
|
44
48
|
if (value == null) continue;
|
|
45
49
|
inlineEnv[inlineVariable] = typeof value === 'string' && value[0] === '"' && value[value.length - 1] === '"' ? JSON.parse(value) : value;
|
|
46
50
|
}
|
|
47
|
-
return
|
|
51
|
+
return multiline`
|
|
48
52
|
const runtime = (${runtime});
|
|
49
53
|
const inline = JSON.parse(${JSON.stringify(JSON.stringify(inlineEnv))});
|
|
50
54
|
|
|
@@ -105,4 +109,4 @@ async function loadEnv({
|
|
|
105
109
|
return env;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
export { magicModuleEnv };
|
|
112
|
+
export { magicModuleEnv, replaceProcessEnv };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { MAGIC_MODULE_REQUEST_ROUTER } from './constants.mjs';
|
|
2
|
-
import {
|
|
1
|
+
import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER } from './constants.mjs';
|
|
2
|
+
import { createMagicModulePlugin } from './shared/magic-module.mjs';
|
|
3
3
|
import { multiline } from './shared/strings.mjs';
|
|
4
4
|
|
|
5
5
|
function magicModuleRequestRouterEntry({
|
|
6
6
|
host,
|
|
7
7
|
port
|
|
8
8
|
} = {}) {
|
|
9
|
-
return
|
|
9
|
+
return createMagicModulePlugin({
|
|
10
10
|
name: '@quilted/request-router',
|
|
11
11
|
sideEffects: true,
|
|
12
|
+
module: MAGIC_MODULE_ENTRY,
|
|
12
13
|
async source() {
|
|
13
14
|
const initialContent = multiline`
|
|
14
15
|
import requestRouter from ${JSON.stringify(MAGIC_MODULE_REQUEST_ROUTER)};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { MAGIC_MODULE_ENTRY } from '../constants.mjs';
|
|
2
|
-
|
|
3
1
|
const VIRTUAL_MODULE_PREFIX = '\0';
|
|
4
2
|
const VIRTUAL_MODULE_POSTFIX = '/module.js';
|
|
5
3
|
function createMagicModulePlugin({
|
|
@@ -28,14 +26,5 @@ function createMagicModulePlugin({
|
|
|
28
26
|
} : undefined
|
|
29
27
|
};
|
|
30
28
|
}
|
|
31
|
-
function createMagicModuleEntryPlugin({
|
|
32
|
-
module = MAGIC_MODULE_ENTRY,
|
|
33
|
-
...options
|
|
34
|
-
}) {
|
|
35
|
-
return createMagicModulePlugin({
|
|
36
|
-
...options,
|
|
37
|
-
module
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
29
|
|
|
41
|
-
export {
|
|
30
|
+
export { createMagicModulePlugin };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import replace from '@rollup/plugin-replace';
|
|
2
|
+
|
|
3
|
+
function smartReplace(values, options) {
|
|
4
|
+
return replace({
|
|
5
|
+
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L108-L119
|
|
6
|
+
delimiters: ['(?<![\\p{L}\\p{N}_$]|(?<!\\.\\.)\\.)(', ')(?:(?<=\\.)|(?![\\p{L}\\p{N}_$]|\\s*?=[^=]))'],
|
|
7
|
+
preventAssignment: true,
|
|
8
|
+
...options,
|
|
9
|
+
values
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async function getNodePlugins() {
|
|
13
|
+
const [{
|
|
14
|
+
default: commonjs
|
|
15
|
+
}, {
|
|
16
|
+
default: json
|
|
17
|
+
}, {
|
|
18
|
+
default: nodeResolve
|
|
19
|
+
}, {
|
|
20
|
+
default: nodeExternals
|
|
21
|
+
}] = await Promise.all([import('@rollup/plugin-commonjs'), import('@rollup/plugin-json'), import('@rollup/plugin-node-resolve'), import('rollup-plugin-node-externals')]);
|
|
22
|
+
return [nodeExternals({}), nodeResolve({
|
|
23
|
+
preferBuiltins: true,
|
|
24
|
+
dedupe: []
|
|
25
|
+
// extensions,
|
|
26
|
+
// exportConditions,
|
|
27
|
+
}), commonjs(), json()];
|
|
28
|
+
}
|
|
29
|
+
function rollupPluginsToArray(plugins) {
|
|
30
|
+
return Array.isArray(plugins) ? [...plugins] : plugins ? [plugins] : [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { getNodePlugins, rollupPluginsToArray, smartReplace };
|