@quilted/rollup 0.1.0 → 0.1.1
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 +7 -0
- package/build/cjs/app.cjs +30 -9
- 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 +15 -0
- package/build/esm/app.mjs +29 -8
- 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 +13 -0
- package/build/esnext/app.esnext +29 -8
- 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 +13 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +5 -5
- 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 +5 -0
- package/build/typescript/shared/rollup.d.ts.map +1 -0
- package/package.json +2 -1
- package/source/app.ts +20 -12
- 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 +38 -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
package/build/cjs/app.cjs
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants.cjs');
|
|
4
|
-
var env = require('./env.cjs');
|
|
5
|
-
var requestRouter = require('./request-router.cjs');
|
|
6
4
|
var strings = require('./shared/strings.cjs');
|
|
7
5
|
var magicModule = require('./shared/magic-module.cjs');
|
|
8
6
|
|
|
9
7
|
function quiltApp({
|
|
10
|
-
env
|
|
8
|
+
env,
|
|
11
9
|
entry
|
|
12
10
|
} = {}) {
|
|
13
11
|
return {
|
|
14
12
|
name: '@quilted/app',
|
|
15
|
-
options(originalOptions) {
|
|
13
|
+
async options(originalOptions) {
|
|
16
14
|
const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
|
|
17
15
|
const newOptions = {
|
|
18
16
|
...originalOptions,
|
|
19
17
|
plugins: newPlugins
|
|
20
18
|
};
|
|
21
|
-
if (env
|
|
22
|
-
|
|
19
|
+
if (env) {
|
|
20
|
+
const {
|
|
21
|
+
magicModuleEnv,
|
|
22
|
+
replaceProcessEnv
|
|
23
|
+
} = await Promise.resolve().then(function () { return require('./env.cjs'); });
|
|
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
|
+
}
|
|
23
40
|
}
|
|
24
41
|
if (entry) {
|
|
25
42
|
newPlugins.push(magicModuleAppComponent({
|
|
@@ -47,13 +64,16 @@ function quiltAppBrowser(options = {}) {
|
|
|
47
64
|
function quiltAppServer(options = {}) {
|
|
48
65
|
return {
|
|
49
66
|
name: '@quilted/app/server',
|
|
50
|
-
options(originalOptions) {
|
|
67
|
+
async options(originalOptions) {
|
|
51
68
|
const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
|
|
69
|
+
const [{
|
|
70
|
+
magicModuleRequestRouterEntry
|
|
71
|
+
}] = await Promise.all([Promise.resolve().then(function () { return require('./request-router.cjs'); })]);
|
|
52
72
|
const newOptions = {
|
|
53
73
|
...originalOptions,
|
|
54
74
|
plugins: newPlugins
|
|
55
75
|
};
|
|
56
|
-
newPlugins.push(
|
|
76
|
+
newPlugins.push(magicModuleRequestRouterEntry());
|
|
57
77
|
newPlugins.push(magicModuleAppRequestRouter(options));
|
|
58
78
|
return newOptions;
|
|
59
79
|
}
|
|
@@ -108,8 +128,9 @@ function magicModuleAppBrowserEntry({
|
|
|
108
128
|
hydrate = true,
|
|
109
129
|
selector = '#app'
|
|
110
130
|
} = {}) {
|
|
111
|
-
return magicModule.
|
|
131
|
+
return magicModule.createMagicModulePlugin({
|
|
112
132
|
name: '@quilted/magic-module/app-browser-entry',
|
|
133
|
+
module: constants.MAGIC_MODULE_ENTRY,
|
|
113
134
|
sideEffects: true,
|
|
114
135
|
async source() {
|
|
115
136
|
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,15 @@
|
|
|
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
|
+
|
|
15
|
+
exports.smartReplace = smartReplace;
|
package/build/esm/app.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS } from './constants.mjs';
|
|
2
|
-
import { magicModuleEnv } from './env.mjs';
|
|
3
|
-
import { magicModuleRequestRouterEntry } from './request-router.mjs';
|
|
1
|
+
import { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY } from './constants.mjs';
|
|
4
2
|
import { multiline } from './shared/strings.mjs';
|
|
5
|
-
import { createMagicModulePlugin
|
|
3
|
+
import { createMagicModulePlugin } from './shared/magic-module.mjs';
|
|
6
4
|
|
|
7
5
|
function quiltApp({
|
|
8
6
|
env,
|
|
@@ -10,14 +8,33 @@ function quiltApp({
|
|
|
10
8
|
} = {}) {
|
|
11
9
|
return {
|
|
12
10
|
name: '@quilted/app',
|
|
13
|
-
options(originalOptions) {
|
|
11
|
+
async options(originalOptions) {
|
|
14
12
|
const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
|
|
15
13
|
const newOptions = {
|
|
16
14
|
...originalOptions,
|
|
17
15
|
plugins: newPlugins
|
|
18
16
|
};
|
|
19
17
|
if (env) {
|
|
20
|
-
|
|
18
|
+
const {
|
|
19
|
+
magicModuleEnv,
|
|
20
|
+
replaceProcessEnv
|
|
21
|
+
} = await import('./env.mjs');
|
|
22
|
+
if (typeof env === 'boolean') {
|
|
23
|
+
newPlugins.push(replaceProcessEnv({
|
|
24
|
+
mode: 'production'
|
|
25
|
+
}));
|
|
26
|
+
newPlugins.push(magicModuleEnv({
|
|
27
|
+
mode: 'production'
|
|
28
|
+
}));
|
|
29
|
+
} else {
|
|
30
|
+
newPlugins.push(replaceProcessEnv({
|
|
31
|
+
mode: env.mode ?? 'production'
|
|
32
|
+
}));
|
|
33
|
+
newPlugins.push(magicModuleEnv({
|
|
34
|
+
mode: 'production',
|
|
35
|
+
...env
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
21
38
|
}
|
|
22
39
|
if (entry) {
|
|
23
40
|
newPlugins.push(magicModuleAppComponent({
|
|
@@ -45,8 +62,11 @@ function quiltAppBrowser(options = {}) {
|
|
|
45
62
|
function quiltAppServer(options = {}) {
|
|
46
63
|
return {
|
|
47
64
|
name: '@quilted/app/server',
|
|
48
|
-
options(originalOptions) {
|
|
65
|
+
async options(originalOptions) {
|
|
49
66
|
const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
|
|
67
|
+
const [{
|
|
68
|
+
magicModuleRequestRouterEntry
|
|
69
|
+
}] = await Promise.all([import('./request-router.mjs')]);
|
|
50
70
|
const newOptions = {
|
|
51
71
|
...originalOptions,
|
|
52
72
|
plugins: newPlugins
|
|
@@ -106,8 +126,9 @@ function magicModuleAppBrowserEntry({
|
|
|
106
126
|
hydrate = true,
|
|
107
127
|
selector = '#app'
|
|
108
128
|
} = {}) {
|
|
109
|
-
return
|
|
129
|
+
return createMagicModulePlugin({
|
|
110
130
|
name: '@quilted/magic-module/app-browser-entry',
|
|
131
|
+
module: MAGIC_MODULE_ENTRY,
|
|
111
132
|
sideEffects: true,
|
|
112
133
|
async source() {
|
|
113
134
|
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,13 @@
|
|
|
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
|
+
|
|
13
|
+
export { smartReplace };
|
package/build/esnext/app.esnext
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS } from './constants.esnext';
|
|
2
|
-
import { magicModuleEnv } from './env.esnext';
|
|
3
|
-
import { magicModuleRequestRouterEntry } from './request-router.esnext';
|
|
1
|
+
import { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY } from './constants.esnext';
|
|
4
2
|
import { multiline } from './shared/strings.esnext';
|
|
5
|
-
import { createMagicModulePlugin
|
|
3
|
+
import { createMagicModulePlugin } from './shared/magic-module.esnext';
|
|
6
4
|
|
|
7
5
|
function quiltApp({
|
|
8
6
|
env,
|
|
@@ -10,14 +8,33 @@ function quiltApp({
|
|
|
10
8
|
} = {}) {
|
|
11
9
|
return {
|
|
12
10
|
name: '@quilted/app',
|
|
13
|
-
options(originalOptions) {
|
|
11
|
+
async options(originalOptions) {
|
|
14
12
|
const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
|
|
15
13
|
const newOptions = {
|
|
16
14
|
...originalOptions,
|
|
17
15
|
plugins: newPlugins
|
|
18
16
|
};
|
|
19
17
|
if (env) {
|
|
20
|
-
|
|
18
|
+
const {
|
|
19
|
+
magicModuleEnv,
|
|
20
|
+
replaceProcessEnv
|
|
21
|
+
} = await import('./env.esnext');
|
|
22
|
+
if (typeof env === 'boolean') {
|
|
23
|
+
newPlugins.push(replaceProcessEnv({
|
|
24
|
+
mode: 'production'
|
|
25
|
+
}));
|
|
26
|
+
newPlugins.push(magicModuleEnv({
|
|
27
|
+
mode: 'production'
|
|
28
|
+
}));
|
|
29
|
+
} else {
|
|
30
|
+
newPlugins.push(replaceProcessEnv({
|
|
31
|
+
mode: env.mode ?? 'production'
|
|
32
|
+
}));
|
|
33
|
+
newPlugins.push(magicModuleEnv({
|
|
34
|
+
mode: 'production',
|
|
35
|
+
...env
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
21
38
|
}
|
|
22
39
|
if (entry) {
|
|
23
40
|
newPlugins.push(magicModuleAppComponent({
|
|
@@ -45,8 +62,11 @@ function quiltAppBrowser(options = {}) {
|
|
|
45
62
|
function quiltAppServer(options = {}) {
|
|
46
63
|
return {
|
|
47
64
|
name: '@quilted/app/server',
|
|
48
|
-
options(originalOptions) {
|
|
65
|
+
async options(originalOptions) {
|
|
49
66
|
const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
|
|
67
|
+
const [{
|
|
68
|
+
magicModuleRequestRouterEntry
|
|
69
|
+
}] = await Promise.all([import('./request-router.esnext')]);
|
|
50
70
|
const newOptions = {
|
|
51
71
|
...originalOptions,
|
|
52
72
|
plugins: newPlugins
|
|
@@ -106,8 +126,9 @@ function magicModuleAppBrowserEntry({
|
|
|
106
126
|
hydrate = true,
|
|
107
127
|
selector = '#app'
|
|
108
128
|
} = {}) {
|
|
109
|
-
return
|
|
129
|
+
return createMagicModulePlugin({
|
|
110
130
|
name: '@quilted/magic-module/app-browser-entry',
|
|
131
|
+
module: MAGIC_MODULE_ENTRY,
|
|
111
132
|
sideEffects: true,
|
|
112
133
|
async source() {
|
|
113
134
|
const reactRootFunction = hydrate ? 'hydrateRoot' : 'createRoot';
|
package/build/esnext/env.esnext
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.esnext';
|
|
4
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.esnext';
|
|
5
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.esnext';
|
|
6
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.esnext';
|
|
7
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.esnext';
|
|
8
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.esnext';
|
|
9
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.esnext';
|
|
10
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.esnext';
|
|
11
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.esnext';
|
|
12
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.esnext';
|
|
13
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.esnext';
|
|
14
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.esnext';
|
|
15
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.esnext';
|
|
16
|
-
import stripIndent from './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext';
|
|
17
|
-
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext';
|
|
18
3
|
import { MAGIC_MODULE_ENV } from './constants.esnext';
|
|
4
|
+
import { multiline } from './shared/strings.esnext';
|
|
5
|
+
import { smartReplace } from './shared/rollup.esnext';
|
|
19
6
|
import { createMagicModulePlugin } from './shared/magic-module.esnext';
|
|
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.esnext';
|
|
2
|
-
import {
|
|
1
|
+
import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER } from './constants.esnext';
|
|
2
|
+
import { createMagicModulePlugin } from './shared/magic-module.esnext';
|
|
3
3
|
import { multiline } from './shared/strings.esnext';
|
|
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.esnext';
|
|
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,13 @@
|
|
|
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
|
+
|
|
13
|
+
export { smartReplace };
|