vike 0.4.227-commit-c9cc081 → 0.4.227-commit-e36b916
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +2 -5
- package/dist/cjs/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -5
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +16 -6
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +6 -8
- package/dist/cjs/node/plugin/plugins/envVars.js +7 -9
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +6 -14
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +1 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +13 -18
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -8
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/isScriptFile.js +4 -4
- package/dist/cjs/utils/parseUrl.js +4 -4
- package/dist/cjs/{node/plugin/shared → utils}/rollupSourceMap.js +4 -4
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +2 -5
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -4
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +16 -6
- package/dist/esm/node/plugin/plugins/devConfig/index.js +6 -8
- package/dist/esm/node/plugin/plugins/envVars.js +8 -10
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +7 -11
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -3
- package/dist/esm/node/plugin/plugins/fileEnv.js +14 -19
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +6 -8
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isScriptFile.js +4 -4
- package/dist/esm/utils/parseUrl.js +4 -4
- package/dist/esm/{node/plugin/shared → utils}/rollupSourceMap.d.ts +4 -4
- package/dist/esm/{node/plugin/shared → utils}/rollupSourceMap.js +4 -4
- package/package.json +1 -1
- package/dist/cjs/node/plugin/shared/getResolvedConfig.js +0 -6
- package/dist/esm/node/plugin/shared/getResolvedConfig.d.ts +0 -2
- package/dist/esm/node/plugin/shared/getResolvedConfig.js +0 -3
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pluginAutoFullBuild = pluginAutoFullBuild;
|
|
7
7
|
exports.isPrerenderForceExit = isPrerenderForceExit;
|
|
8
|
-
const getResolvedConfig_js_1 = require("../../shared/getResolvedConfig.js");
|
|
9
8
|
const vite_1 = require("vite");
|
|
10
9
|
const utils_js_1 = require("../../utils.js");
|
|
11
10
|
const runPrerender_js_1 = require("../../../prerender/runPrerender.js");
|
|
@@ -21,7 +20,7 @@ const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
|
21
20
|
(0, utils_js_1.assertIsSingleModuleInstance)('build/pluginAutoFullBuild.ts');
|
|
22
21
|
let forceExit = false;
|
|
23
22
|
function pluginAutoFullBuild() {
|
|
24
|
-
let
|
|
23
|
+
let config;
|
|
25
24
|
let vikeConfig;
|
|
26
25
|
return [
|
|
27
26
|
{
|
|
@@ -30,7 +29,7 @@ function pluginAutoFullBuild() {
|
|
|
30
29
|
enforce: 'pre',
|
|
31
30
|
async configResolved(config_) {
|
|
32
31
|
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config_);
|
|
33
|
-
|
|
32
|
+
config = config_;
|
|
34
33
|
abortViteBuildSsr(vikeConfig);
|
|
35
34
|
},
|
|
36
35
|
writeBundle: {
|
|
@@ -39,7 +38,6 @@ function pluginAutoFullBuild() {
|
|
|
39
38
|
order: 'pre',
|
|
40
39
|
*/
|
|
41
40
|
async handler(options, bundle) {
|
|
42
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
43
41
|
await (0, handleAssetsManifest_js_1.handleAssetsManifest)(config, this.environment, options, bundle);
|
|
44
42
|
await triggerFullBuild(config, vikeConfig, this.environment, bundle);
|
|
45
43
|
}
|
|
@@ -53,7 +51,6 @@ function pluginAutoFullBuild() {
|
|
|
53
51
|
sequential: true,
|
|
54
52
|
order: 'post',
|
|
55
53
|
handler() {
|
|
56
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
57
54
|
(0, utils_js_1.onSetupBuild)();
|
|
58
55
|
(0, handleAssetsManifest_js_1.handleAssetsManifest_assertUsageCssTarget)(config);
|
|
59
56
|
if (forceExit &&
|
|
@@ -9,20 +9,17 @@
|
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.pluginDistPackageJsonFile = pluginDistPackageJsonFile;
|
|
12
|
-
// TODO/refactor: prefix all other plugins with `plugin` as well?
|
|
13
|
-
const getResolvedConfig_js_1 = require("../../shared/getResolvedConfig.js");
|
|
14
12
|
const rollupIsEsm_js_1 = require("../../shared/rollupIsEsm.js");
|
|
15
13
|
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
16
14
|
function pluginDistPackageJsonFile() {
|
|
17
|
-
let
|
|
15
|
+
let config;
|
|
18
16
|
return {
|
|
19
17
|
name: 'vike:build:pluginDistPackageJsonFile',
|
|
20
18
|
apply: 'build',
|
|
21
19
|
configResolved(config_) {
|
|
22
|
-
|
|
20
|
+
config = config_;
|
|
23
21
|
},
|
|
24
22
|
generateBundle(options, bundle) {
|
|
25
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
26
23
|
if (!(0, isViteServerBuild_js_1.isViteServerBuild)(config))
|
|
27
24
|
return;
|
|
28
25
|
const isEsm = (0, rollupIsEsm_js_1.rollupIsEsm)(options);
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pluginModuleBanner = pluginModuleBanner;
|
|
7
|
-
const getResolvedConfig_js_1 = require("../../shared/getResolvedConfig.js");
|
|
8
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
9
8
|
const utils_js_1 = require("../../utils.js");
|
|
10
9
|
const virtual_files_js_1 = require("../../../shared/virtual-files.js");
|
|
@@ -13,24 +12,34 @@ const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
|
13
12
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
14
13
|
const vikeModuleBannerPlaceholder = 'vikeModuleBannerPlaceholder';
|
|
15
14
|
function pluginModuleBanner() {
|
|
16
|
-
let
|
|
15
|
+
let config;
|
|
16
|
+
let disabled = false;
|
|
17
17
|
return {
|
|
18
18
|
name: 'vike:pluginModuleBanner',
|
|
19
19
|
enforce: 'post',
|
|
20
20
|
apply: 'build',
|
|
21
21
|
configResolved(config_) {
|
|
22
|
-
|
|
22
|
+
config = config_;
|
|
23
|
+
if (config.build.minify && config.build.minify !== 'esbuild') {
|
|
24
|
+
// Doesn't work upon `config.build.minify === 'terser'`
|
|
25
|
+
// https://github.com/vikejs/vike/issues/2315
|
|
26
|
+
disabled = true;
|
|
27
|
+
}
|
|
23
28
|
},
|
|
24
29
|
generateBundle: {
|
|
25
30
|
order: 'post',
|
|
26
31
|
handler(_options, bundle) {
|
|
27
|
-
|
|
32
|
+
if (disabled)
|
|
33
|
+
return;
|
|
28
34
|
for (const module of Object.values(bundle)) {
|
|
29
35
|
if (module.type === 'chunk') {
|
|
30
36
|
if ((0, isViteServerBuild_js_1.isViteServerBuild)(config)) {
|
|
31
37
|
const codeOld = module.code;
|
|
32
38
|
const codeNew = codeOld.replace(/vikeModuleBannerPlaceholder\("([^"]*)"\);/g, '/* $1 [vike:pluginModuleBanner] */');
|
|
33
|
-
|
|
39
|
+
if (codeNew.includes(vikeModuleBannerPlaceholder)) {
|
|
40
|
+
console.log('codeNew', codeNew);
|
|
41
|
+
(0, utils_js_1.assert)(false);
|
|
42
|
+
}
|
|
34
43
|
module.code = codeNew;
|
|
35
44
|
}
|
|
36
45
|
else {
|
|
@@ -43,7 +52,8 @@ function pluginModuleBanner() {
|
|
|
43
52
|
transform: {
|
|
44
53
|
order: 'post',
|
|
45
54
|
handler(code, id, options) {
|
|
46
|
-
|
|
55
|
+
if (disabled)
|
|
56
|
+
return;
|
|
47
57
|
if (!(0, isViteServerBuild_js_1.isViteServerBuild_safe)(config, options))
|
|
48
58
|
return;
|
|
49
59
|
if (id.startsWith('\0'))
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.devConfig = devConfig;
|
|
7
7
|
exports.logDockerHint = logDockerHint;
|
|
8
|
-
const getResolvedConfig_js_1 = require("../../shared/getResolvedConfig.js");
|
|
9
8
|
const determineOptimizeDeps_js_1 = require("./determineOptimizeDeps.js");
|
|
10
9
|
const determineFsAllowList_js_1 = require("./determineFsAllowList.js");
|
|
11
10
|
const addSsrMiddleware_js_1 = require("../../shared/addSsrMiddleware.js");
|
|
@@ -18,7 +17,7 @@ if ((0, isErrorDebug_js_1.isErrorDebug)()) {
|
|
|
18
17
|
Error.stackTraceLimit = Infinity;
|
|
19
18
|
}
|
|
20
19
|
function devConfig() {
|
|
21
|
-
let
|
|
20
|
+
let config;
|
|
22
21
|
return [
|
|
23
22
|
{
|
|
24
23
|
name: 'vike:devConfig',
|
|
@@ -63,14 +62,14 @@ function devConfig() {
|
|
|
63
62
|
};
|
|
64
63
|
},
|
|
65
64
|
async configResolved(config_) {
|
|
66
|
-
|
|
67
|
-
await (0, determineOptimizeDeps_js_1.determineOptimizeDeps)(
|
|
68
|
-
await (0, determineFsAllowList_js_1.determineFsAllowList)(
|
|
65
|
+
config = config_;
|
|
66
|
+
await (0, determineOptimizeDeps_js_1.determineOptimizeDeps)(config);
|
|
67
|
+
await (0, determineFsAllowList_js_1.determineFsAllowList)(config);
|
|
69
68
|
if (!(0, isErrorDebug_js_1.isErrorDebug)()) {
|
|
70
69
|
await (0, getHttpRequestAsyncStore_js_1.installHttpRequestAsyncStore)();
|
|
71
|
-
(0, loggerVite_js_1.improveViteLogs)(
|
|
70
|
+
(0, loggerVite_js_1.improveViteLogs)(config);
|
|
72
71
|
}
|
|
73
|
-
logDockerHint(
|
|
72
|
+
logDockerHint(config.server.host);
|
|
74
73
|
}
|
|
75
74
|
},
|
|
76
75
|
{
|
|
@@ -81,7 +80,6 @@ function devConfig() {
|
|
|
81
80
|
configureServer: {
|
|
82
81
|
order: 'post',
|
|
83
82
|
handler(server) {
|
|
84
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(server?.config, vite5Config);
|
|
85
83
|
const hasHonoViteDevServer = !!config.plugins.find((p) => p.name === '@hono/vite-dev-server');
|
|
86
84
|
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
87
85
|
return;
|
|
@@ -10,30 +10,28 @@ const utils_js_1 = require("../utils.js");
|
|
|
10
10
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
11
11
|
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
12
12
|
const isViteServerBuild_js_1 = require("../shared/isViteServerBuild.js");
|
|
13
|
-
const getResolvedConfig_js_1 = require("../shared/getResolvedConfig.js");
|
|
14
13
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
15
14
|
// - Make import.meta.env work inside +config.js
|
|
16
15
|
// - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
|
|
17
16
|
// - Or stop using Vite's `mode` implemention and have Vike implement its own `mode` feature? (So that the only dependencies are `$ vike build --mode staging` and `$ MODE=staging vike build`.)
|
|
18
17
|
const PUBLIC_ENV_PREFIX = 'PUBLIC_ENV__';
|
|
19
|
-
const
|
|
18
|
+
const PUBLIC_ENV_ALLOWLIST = [
|
|
20
19
|
// https://github.com/vikejs/vike/issues/1724
|
|
21
20
|
'STORYBOOK'
|
|
22
21
|
];
|
|
23
22
|
function envVarsPlugin() {
|
|
24
23
|
let envsAll;
|
|
25
|
-
let
|
|
24
|
+
let config;
|
|
26
25
|
return {
|
|
27
26
|
name: 'vike:envVars',
|
|
28
27
|
enforce: 'post',
|
|
29
28
|
configResolved(config_) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
envsAll = (0, vite_1.loadEnv)(
|
|
33
|
-
|
|
29
|
+
config = config_;
|
|
30
|
+
config.command;
|
|
31
|
+
envsAll = (0, vite_1.loadEnv)(config.mode, config.envDir || config.root, '');
|
|
32
|
+
config.plugins.sort((0, utils_js_1.lowerFirst)((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
|
|
34
33
|
},
|
|
35
34
|
transform(code, id, options) {
|
|
36
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
37
35
|
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
38
36
|
(0, utils_js_1.assertPosixPath)(id);
|
|
39
37
|
if (id.includes('/node_modules/'))
|
|
@@ -57,7 +55,7 @@ function envVarsPlugin() {
|
|
|
57
55
|
const envStatementRegExStr = (0, utils_js_1.escapeRegex)(envStatement) + '\\b';
|
|
58
56
|
// Security check
|
|
59
57
|
{
|
|
60
|
-
const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !
|
|
58
|
+
const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !PUBLIC_ENV_ALLOWLIST.includes(envName);
|
|
61
59
|
if (isPrivate && isClientSide) {
|
|
62
60
|
if (!new RegExp(envStatementRegExStr).test(code))
|
|
63
61
|
return;
|
|
@@ -7,17 +7,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.extractAssetsRE = void 0;
|
|
9
9
|
exports.extractAssetsPlugin = extractAssetsPlugin;
|
|
10
|
-
// Workaround to make client-side bundles include the CSS imports living in server-side-only code.
|
|
11
|
-
// - This is needed for HTML-only pages, and React Server Components.
|
|
12
|
-
// - We recommend using the debug flag to get an idea of how this plugin works: `$ DEBUG=vike:extractAssets pnpm exec vike build`. Then have a look at `dist/client/manifest.json` and see how `.page.server.js` entries have zero JavaScript but only CSS.
|
|
13
|
-
// - This appraoch supports import path aliases `vite.config.js#resolve.alias` https://vitejs.dev/config/#resolve-alias
|
|
14
|
-
const getResolvedConfig_js_1 = require("../shared/getResolvedConfig.js");
|
|
15
10
|
const utils_js_1 = require("../utils.js");
|
|
16
11
|
const virtual_files_js_1 = require("../../shared/virtual-files.js");
|
|
17
12
|
const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
18
13
|
const isAsset_js_1 = require("../shared/isAsset.js");
|
|
19
14
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
20
|
-
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
21
15
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
22
16
|
const handleAssetsManifest_js_1 = require("./build/handleAssetsManifest.js");
|
|
23
17
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
@@ -31,7 +25,7 @@ const urlRE = /(\?|&)url(?:&|$)/;
|
|
|
31
25
|
const EMPTY_MODULE_ID = 'virtual:vike:empty-module';
|
|
32
26
|
const debug = (0, utils_js_1.createDebugger)('vike:extractAssets');
|
|
33
27
|
function extractAssetsPlugin() {
|
|
34
|
-
let
|
|
28
|
+
let config;
|
|
35
29
|
let vikeConfig;
|
|
36
30
|
let isFixEnabled;
|
|
37
31
|
return [
|
|
@@ -42,7 +36,6 @@ function extractAssetsPlugin() {
|
|
|
42
36
|
apply: 'build',
|
|
43
37
|
enforce: 'post',
|
|
44
38
|
async transform(src, id, options) {
|
|
45
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
46
39
|
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
47
40
|
if (!extractAssetsRE.test(id)) {
|
|
48
41
|
return;
|
|
@@ -59,7 +52,7 @@ function extractAssetsPlugin() {
|
|
|
59
52
|
const moduleNames = getImportedModules(importStatements);
|
|
60
53
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
61
54
|
debugTransformResult(id, code, importStatements);
|
|
62
|
-
return (0,
|
|
55
|
+
return (0, utils_js_1.rollupSourceMapRemove)(code);
|
|
63
56
|
}
|
|
64
57
|
},
|
|
65
58
|
// This plugin appends `?extractAssets` to module IDs
|
|
@@ -71,7 +64,6 @@ function extractAssetsPlugin() {
|
|
|
71
64
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
72
65
|
enforce: 'pre',
|
|
73
66
|
async resolveId(source, importer, options) {
|
|
74
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
75
67
|
if ((0, isViteServerBuild_js_1.isViteServerBuild_safe)(config, options)) {
|
|
76
68
|
// When building for the server, there should never be a `?extractAssets` query
|
|
77
69
|
(0, utils_js_1.assert)(!extractAssetsRE.test(source));
|
|
@@ -147,12 +139,12 @@ function extractAssetsPlugin() {
|
|
|
147
139
|
{
|
|
148
140
|
name: 'vike:extractAssets-4',
|
|
149
141
|
async configResolved(config_) {
|
|
150
|
-
|
|
151
|
-
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(
|
|
152
|
-
isFixEnabled = (0, handleAssetsManifest_js_1.handleAssetsManifest_isFixEnabled)(
|
|
142
|
+
config = config_;
|
|
143
|
+
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
144
|
+
isFixEnabled = (0, handleAssetsManifest_js_1.handleAssetsManifest_isFixEnabled)(config);
|
|
153
145
|
if (!isFixEnabled) {
|
|
154
146
|
// https://github.com/vikejs/vike/issues/1060
|
|
155
|
-
(0, utils_js_1.assertUsage)(!
|
|
147
|
+
(0, utils_js_1.assertUsage)(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
156
148
|
}
|
|
157
149
|
}
|
|
158
150
|
}
|
|
@@ -5,7 +5,6 @@ exports.extractExportNamesPlugin = extractExportNamesPlugin;
|
|
|
5
5
|
exports.isUsingClientRouter = isUsingClientRouter;
|
|
6
6
|
const utils_js_1 = require("../utils.js");
|
|
7
7
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
8
|
-
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
9
8
|
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
10
9
|
const isViteServerBuild_js_1 = require("../shared/isViteServerBuild.js");
|
|
11
10
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
@@ -42,7 +41,7 @@ async function getExtractExportNamesCode(src, isClientSide, isProduction, id) {
|
|
|
42
41
|
globalObject.usesClientRouter = true;
|
|
43
42
|
}
|
|
44
43
|
const code = getCode(exportNames, wildcardReExports, isClientSide, isProduction, id);
|
|
45
|
-
return (0,
|
|
44
|
+
return (0, utils_js_1.rollupSourceMapRemove)(code);
|
|
46
45
|
}
|
|
47
46
|
function getCode(exportNames, wildcardReExports, isClientSide, isProduction, id) {
|
|
48
47
|
let code = '';
|
|
@@ -4,29 +4,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fileEnv = fileEnv;
|
|
7
|
-
const getResolvedConfig_js_1 = require("../shared/getResolvedConfig.js");
|
|
8
7
|
const utils_js_1 = require("../utils.js");
|
|
9
8
|
const extractAssetsPlugin_js_1 = require("./extractAssetsPlugin.js");
|
|
10
9
|
const extractExportNamesPlugin_js_1 = require("./extractExportNamesPlugin.js");
|
|
11
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
11
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
13
|
-
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
14
12
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
15
13
|
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
16
14
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
17
15
|
function fileEnv() {
|
|
18
|
-
let
|
|
16
|
+
let config;
|
|
19
17
|
let viteDevServer;
|
|
20
18
|
return {
|
|
21
19
|
name: 'vike:fileEnv',
|
|
22
20
|
load(id, options) {
|
|
23
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
24
21
|
// In build, we use generateBundle() instead of the load() hook. Using load() works for dynamic imports in dev thanks to Vite's lazy transpiling, but it doesn't work in build because Rollup transpiles any dynamically imported module even if it's never actually imported.
|
|
25
22
|
if (!viteDevServer)
|
|
26
23
|
return;
|
|
27
24
|
if (!(0, getVikeConfig_js_1.isV1Design)(config))
|
|
28
25
|
return;
|
|
29
|
-
if (skip(
|
|
26
|
+
if (skip(id))
|
|
30
27
|
return;
|
|
31
28
|
// For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
|
|
32
29
|
if (id.endsWith('?direct'))
|
|
@@ -36,36 +33,34 @@ function fileEnv() {
|
|
|
36
33
|
const importers = Array.from(moduleInfo.importers)
|
|
37
34
|
.map((m) => m.id)
|
|
38
35
|
.filter((id) => id !== null);
|
|
39
|
-
assertFileEnv(
|
|
36
|
+
assertFileEnv(id, !!options?.ssr, importers,
|
|
40
37
|
// In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
|
|
41
38
|
true);
|
|
42
39
|
},
|
|
43
40
|
// In production, we have to use transform() to replace modules with a runtime error because generateBundle() doesn't work for dynamic imports. In production, dynamic imports can only be verified at runtime.
|
|
44
41
|
async transform(code, id, options) {
|
|
45
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
46
42
|
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
47
43
|
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
48
44
|
if (viteDevServer)
|
|
49
45
|
return;
|
|
50
|
-
if (skip(
|
|
46
|
+
if (skip(id))
|
|
51
47
|
return;
|
|
52
48
|
const isServerSide = !!options?.ssr;
|
|
53
49
|
if (!isWrongEnv(id, isServerSide))
|
|
54
50
|
return;
|
|
55
51
|
const { importers } = this.getModuleInfo(id);
|
|
56
52
|
// Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code splitted.
|
|
57
|
-
const errMsg = getErrorMessage(
|
|
53
|
+
const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
|
|
58
54
|
// We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
|
|
59
55
|
const { exportNames } = await (0, parseEsModule_js_1.getExportNames)(code);
|
|
60
|
-
return (0,
|
|
56
|
+
return (0, utils_js_1.rollupSourceMapRemove)([
|
|
61
57
|
`throw new Error(${JSON.stringify(errMsg)});`,
|
|
62
58
|
...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`)
|
|
63
59
|
].join('\n'));
|
|
64
60
|
},
|
|
65
61
|
generateBundle() {
|
|
66
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
67
62
|
Array.from(this.getModuleIds())
|
|
68
|
-
.filter((id) => !skip(
|
|
63
|
+
.filter((id) => !skip(id))
|
|
69
64
|
.forEach((moduleId) => {
|
|
70
65
|
const mod = this.getModuleInfo(moduleId);
|
|
71
66
|
const { importers } = mod;
|
|
@@ -76,20 +71,20 @@ function fileEnv() {
|
|
|
76
71
|
*/
|
|
77
72
|
return;
|
|
78
73
|
}
|
|
79
|
-
assertFileEnv(
|
|
74
|
+
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
|
80
75
|
});
|
|
81
76
|
},
|
|
82
77
|
configResolved(config_) {
|
|
83
|
-
|
|
78
|
+
config = config_;
|
|
84
79
|
},
|
|
85
80
|
configureServer(viteDevServer_) {
|
|
86
81
|
viteDevServer = viteDevServer_;
|
|
87
82
|
}
|
|
88
83
|
};
|
|
89
|
-
function assertFileEnv(
|
|
84
|
+
function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
|
|
90
85
|
if (!isWrongEnv(moduleId, isServerSide))
|
|
91
86
|
return;
|
|
92
|
-
const errMsg = getErrorMessage(
|
|
87
|
+
const errMsg = getErrorMessage(moduleId, isServerSide, importers, onlyWarn, false);
|
|
93
88
|
if (onlyWarn) {
|
|
94
89
|
(0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
|
|
95
90
|
}
|
|
@@ -97,7 +92,7 @@ function fileEnv() {
|
|
|
97
92
|
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
98
93
|
}
|
|
99
94
|
}
|
|
100
|
-
function getErrorMessage(
|
|
95
|
+
function getErrorMessage(moduleId, isServerSide, importers, onlyWarn, noColor) {
|
|
101
96
|
const modulePath = getModulePath(moduleId);
|
|
102
97
|
const envActual = isServerSide ? 'server' : 'client';
|
|
103
98
|
const envExpect = isServerSide ? 'client' : 'server';
|
|
@@ -122,7 +117,7 @@ function fileEnv() {
|
|
|
122
117
|
const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
|
|
123
118
|
return modulePath.includes(suffixWrong);
|
|
124
119
|
}
|
|
125
|
-
function skip(
|
|
120
|
+
function skip(id) {
|
|
126
121
|
// TODO/v1-release: remove
|
|
127
122
|
if (extractAssetsPlugin_js_1.extractAssetsRE.test(id) || extractExportNamesPlugin_js_1.extractExportNamesRE.test(id))
|
|
128
123
|
return true;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.importUserCode = importUserCode;
|
|
7
|
-
const getResolvedConfig_js_1 = require("../../shared/getResolvedConfig.js");
|
|
8
7
|
const vite_1 = require("vite");
|
|
9
8
|
const getVirtualFilePageConfigValuesAll_js_1 = require("./v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js");
|
|
10
9
|
const getVirtualFileImportUserCode_js_1 = require("./getVirtualFileImportUserCode.js");
|
|
@@ -19,16 +18,16 @@ const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
|
19
18
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
20
19
|
const crawlPlusFiles_js_1 = require("./v1-design/getVikeConfig/crawlPlusFiles.js");
|
|
21
20
|
function importUserCode() {
|
|
22
|
-
let
|
|
21
|
+
let config;
|
|
23
22
|
let vikeConfig;
|
|
24
23
|
return {
|
|
25
24
|
name: 'vike:importUserCode',
|
|
26
25
|
async configResolved(config_) {
|
|
27
26
|
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config_);
|
|
28
|
-
|
|
27
|
+
config = config_;
|
|
29
28
|
// TODO/v1-release: remove
|
|
30
|
-
if (!(0, getVikeConfig_js_1.isV1Design)(
|
|
31
|
-
|
|
29
|
+
if (!(0, getVikeConfig_js_1.isV1Design)(config))
|
|
30
|
+
config.experimental.importGlobRestoreExtension = true;
|
|
32
31
|
},
|
|
33
32
|
resolveId(id) {
|
|
34
33
|
if ((0, virtual_files_js_1.isVirtualFileId)(id)) {
|
|
@@ -37,7 +36,7 @@ function importUserCode() {
|
|
|
37
36
|
},
|
|
38
37
|
async handleHotUpdate(ctx) {
|
|
39
38
|
try {
|
|
40
|
-
return await handleHotUpdate(ctx,
|
|
39
|
+
return await handleHotUpdate(ctx, config);
|
|
41
40
|
}
|
|
42
41
|
catch (err) {
|
|
43
42
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -46,7 +45,6 @@ function importUserCode() {
|
|
|
46
45
|
}
|
|
47
46
|
},
|
|
48
47
|
async load(id, options) {
|
|
49
|
-
const config = (0, getResolvedConfig_js_1.getResolvedConfig)(this.environment?.config, vite5Config);
|
|
50
48
|
if (!(0, virtual_files_js_1.isVirtualFileId)(id))
|
|
51
49
|
return undefined;
|
|
52
50
|
id = (0, virtual_files_js_1.getVirtualFileId)(id);
|
|
@@ -62,7 +60,7 @@ function importUserCode() {
|
|
|
62
60
|
}
|
|
63
61
|
},
|
|
64
62
|
configureServer(server) {
|
|
65
|
-
handleFileAddRemove(server,
|
|
63
|
+
handleFileAddRemove(server, config);
|
|
66
64
|
}
|
|
67
65
|
};
|
|
68
66
|
}
|
|
@@ -45,3 +45,4 @@ __exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
|
|
|
45
45
|
__exportStar(require("../../utils/isEqualStringList.js"), exports);
|
|
46
46
|
__exportStar(require("../../utils/isDocker.js"), exports);
|
|
47
47
|
__exportStar(require("../../utils/isVitest.js"), exports);
|
|
48
|
+
__exportStar(require("../../utils/rollupSourceMap.js"), exports);
|
|
@@ -72,7 +72,7 @@ async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
|
72
72
|
if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'urlLogical')) {
|
|
73
73
|
(0, utils_js_1.assertUsageUrlPathnameAbsolute)(
|
|
74
74
|
// We skip validation and type-cast instead of assertUsage() in order to save client-side KBs
|
|
75
|
-
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext: { urlLogical } }')}
|
|
75
|
+
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext: { urlLogical } }')} and ${picocolors_1.default.cyan('urlLogical')}`);
|
|
76
76
|
}
|
|
77
77
|
(0, assertPageContextProvidedByUser_js_1.assertPageContextProvidedByUser)(hookReturn.pageContext, {
|
|
78
78
|
hookFilePath: onBeforeRouteHook.hookFilePath,
|
|
@@ -8,12 +8,12 @@ const assert_js_1 = require("./assert.js");
|
|
|
8
8
|
// We can't use a RegExp:
|
|
9
9
|
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
10
10
|
// - Vite's `import.meta.glob()` uses Micromatch
|
|
11
|
-
// - We need this to be a
|
|
11
|
+
// - We need this to be a allowlist because:
|
|
12
12
|
// - A pattern `*([a-zA-Z0-9]` doesn't work.
|
|
13
13
|
// - Because of ReScript: `.res` are ReScript source files which need to be ignored. (The ReScript compiler generates `.js` files alongside `.res` files.)
|
|
14
|
-
// -
|
|
15
|
-
// - We cannot implement a
|
|
16
|
-
// - A post `import.meta.glob()`
|
|
14
|
+
// - Block listing doesn't work.
|
|
15
|
+
// - We cannot implement a blocklist with a glob pattern.
|
|
16
|
+
// - A post `import.meta.glob()` blocklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
|
|
17
17
|
// prettier-ignore
|
|
18
18
|
// biome-ignore format:
|
|
19
19
|
const extJavaScript = [
|
|
@@ -186,14 +186,14 @@ function parseProtocol(uri) {
|
|
|
186
186
|
return { protocol, uriWithoutProtocol };
|
|
187
187
|
}
|
|
188
188
|
function isUrlProtocol(protocol) {
|
|
189
|
-
// Is there an
|
|
190
|
-
// - If the
|
|
191
|
-
const
|
|
189
|
+
// Is there an alternative to having a blocklist?
|
|
190
|
+
// - If the blocklist becomes too big, maybe use a allowlist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
|
|
191
|
+
const blocklist = [
|
|
192
192
|
// https://docs.ipfs.tech/how-to/address-ipfs-on-web
|
|
193
193
|
'ipfs://',
|
|
194
194
|
'ipns://'
|
|
195
195
|
];
|
|
196
|
-
if (
|
|
196
|
+
if (blocklist.includes(protocol))
|
|
197
197
|
return false;
|
|
198
198
|
return protocol.endsWith('://');
|
|
199
199
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.rollupSourceMapRemove = rollupSourceMapRemove;
|
|
4
|
+
exports.rollupSourceMapPassthrough = rollupSourceMapPassthrough;
|
|
5
5
|
// https://rollupjs.org/guide/en/#source-code-transformations
|
|
6
6
|
/** Remove entire source mapping, to save KBs. */
|
|
7
|
-
function
|
|
7
|
+
function rollupSourceMapRemove(code) {
|
|
8
8
|
return {
|
|
9
9
|
code,
|
|
10
10
|
map: { mappings: '' }
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
/** Don't provide any source map, pass through current source map instead. */
|
|
14
|
-
function
|
|
14
|
+
function rollupSourceMapPassthrough(code) {
|
|
15
15
|
return {
|
|
16
16
|
code,
|
|
17
17
|
map: null
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getResolvedConfig } from '../../shared/getResolvedConfig.js';
|
|
2
1
|
export { pluginAutoFullBuild };
|
|
3
2
|
export { isPrerenderForceExit };
|
|
4
3
|
import { build } from 'vite';
|
|
@@ -16,7 +15,7 @@ import { isViteClientBuild, isViteServerBuild_onlySsrEnv } from '../../shared/is
|
|
|
16
15
|
assertIsSingleModuleInstance('build/pluginAutoFullBuild.ts');
|
|
17
16
|
let forceExit = false;
|
|
18
17
|
function pluginAutoFullBuild() {
|
|
19
|
-
let
|
|
18
|
+
let config;
|
|
20
19
|
let vikeConfig;
|
|
21
20
|
return [
|
|
22
21
|
{
|
|
@@ -25,7 +24,7 @@ function pluginAutoFullBuild() {
|
|
|
25
24
|
enforce: 'pre',
|
|
26
25
|
async configResolved(config_) {
|
|
27
26
|
vikeConfig = await getVikeConfig(config_);
|
|
28
|
-
|
|
27
|
+
config = config_;
|
|
29
28
|
abortViteBuildSsr(vikeConfig);
|
|
30
29
|
},
|
|
31
30
|
writeBundle: {
|
|
@@ -34,7 +33,6 @@ function pluginAutoFullBuild() {
|
|
|
34
33
|
order: 'pre',
|
|
35
34
|
*/
|
|
36
35
|
async handler(options, bundle) {
|
|
37
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
38
36
|
await handleAssetsManifest(config, this.environment, options, bundle);
|
|
39
37
|
await triggerFullBuild(config, vikeConfig, this.environment, bundle);
|
|
40
38
|
}
|
|
@@ -48,7 +46,6 @@ function pluginAutoFullBuild() {
|
|
|
48
46
|
sequential: true,
|
|
49
47
|
order: 'post',
|
|
50
48
|
handler() {
|
|
51
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
52
49
|
onSetupBuild();
|
|
53
50
|
handleAssetsManifest_assertUsageCssTarget(config);
|
|
54
51
|
if (forceExit &&
|
|
@@ -7,20 +7,18 @@
|
|
|
7
7
|
* Reproduction: https://github.com/brillout/vite-plugin-ssr-server-import-syntax
|
|
8
8
|
*/
|
|
9
9
|
// TODO/refactor: prefix all other plugins with `plugin` as well?
|
|
10
|
-
import { getResolvedConfig } from '../../shared/getResolvedConfig.js';
|
|
11
10
|
export { pluginDistPackageJsonFile };
|
|
12
11
|
import { rollupIsEsm } from '../../shared/rollupIsEsm.js';
|
|
13
12
|
import { isViteServerBuild } from '../../shared/isViteServerBuild.js';
|
|
14
13
|
function pluginDistPackageJsonFile() {
|
|
15
|
-
let
|
|
14
|
+
let config;
|
|
16
15
|
return {
|
|
17
16
|
name: 'vike:build:pluginDistPackageJsonFile',
|
|
18
17
|
apply: 'build',
|
|
19
18
|
configResolved(config_) {
|
|
20
|
-
|
|
19
|
+
config = config_;
|
|
21
20
|
},
|
|
22
21
|
generateBundle(options, bundle) {
|
|
23
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
24
22
|
if (!isViteServerBuild(config))
|
|
25
23
|
return;
|
|
26
24
|
const isEsm = rollupIsEsm(options);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getResolvedConfig } from '../../shared/getResolvedConfig.js';
|
|
2
1
|
export { pluginModuleBanner };
|
|
3
2
|
import MagicString from 'magic-string';
|
|
4
3
|
import { assert } from '../../utils.js';
|
|
@@ -8,24 +7,34 @@ import { isViteServerBuild, isViteServerBuild_safe } from '../../shared/isViteSe
|
|
|
8
7
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
9
8
|
const vikeModuleBannerPlaceholder = 'vikeModuleBannerPlaceholder';
|
|
10
9
|
function pluginModuleBanner() {
|
|
11
|
-
let
|
|
10
|
+
let config;
|
|
11
|
+
let disabled = false;
|
|
12
12
|
return {
|
|
13
13
|
name: 'vike:pluginModuleBanner',
|
|
14
14
|
enforce: 'post',
|
|
15
15
|
apply: 'build',
|
|
16
16
|
configResolved(config_) {
|
|
17
|
-
|
|
17
|
+
config = config_;
|
|
18
|
+
if (config.build.minify && config.build.minify !== 'esbuild') {
|
|
19
|
+
// Doesn't work upon `config.build.minify === 'terser'`
|
|
20
|
+
// https://github.com/vikejs/vike/issues/2315
|
|
21
|
+
disabled = true;
|
|
22
|
+
}
|
|
18
23
|
},
|
|
19
24
|
generateBundle: {
|
|
20
25
|
order: 'post',
|
|
21
26
|
handler(_options, bundle) {
|
|
22
|
-
|
|
27
|
+
if (disabled)
|
|
28
|
+
return;
|
|
23
29
|
for (const module of Object.values(bundle)) {
|
|
24
30
|
if (module.type === 'chunk') {
|
|
25
31
|
if (isViteServerBuild(config)) {
|
|
26
32
|
const codeOld = module.code;
|
|
27
33
|
const codeNew = codeOld.replace(/vikeModuleBannerPlaceholder\("([^"]*)"\);/g, '/* $1 [vike:pluginModuleBanner] */');
|
|
28
|
-
|
|
34
|
+
if (codeNew.includes(vikeModuleBannerPlaceholder)) {
|
|
35
|
+
console.log('codeNew', codeNew);
|
|
36
|
+
assert(false);
|
|
37
|
+
}
|
|
29
38
|
module.code = codeNew;
|
|
30
39
|
}
|
|
31
40
|
else {
|
|
@@ -38,7 +47,8 @@ function pluginModuleBanner() {
|
|
|
38
47
|
transform: {
|
|
39
48
|
order: 'post',
|
|
40
49
|
handler(code, id, options) {
|
|
41
|
-
|
|
50
|
+
if (disabled)
|
|
51
|
+
return;
|
|
42
52
|
if (!isViteServerBuild_safe(config, options))
|
|
43
53
|
return;
|
|
44
54
|
if (id.startsWith('\0'))
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getResolvedConfig } from '../../shared/getResolvedConfig.js';
|
|
2
1
|
export { devConfig };
|
|
3
2
|
export { logDockerHint };
|
|
4
3
|
import { determineOptimizeDeps } from './determineOptimizeDeps.js';
|
|
@@ -13,7 +12,7 @@ if (isErrorDebug()) {
|
|
|
13
12
|
Error.stackTraceLimit = Infinity;
|
|
14
13
|
}
|
|
15
14
|
function devConfig() {
|
|
16
|
-
let
|
|
15
|
+
let config;
|
|
17
16
|
return [
|
|
18
17
|
{
|
|
19
18
|
name: 'vike:devConfig',
|
|
@@ -58,14 +57,14 @@ function devConfig() {
|
|
|
58
57
|
};
|
|
59
58
|
},
|
|
60
59
|
async configResolved(config_) {
|
|
61
|
-
|
|
62
|
-
await determineOptimizeDeps(
|
|
63
|
-
await determineFsAllowList(
|
|
60
|
+
config = config_;
|
|
61
|
+
await determineOptimizeDeps(config);
|
|
62
|
+
await determineFsAllowList(config);
|
|
64
63
|
if (!isErrorDebug()) {
|
|
65
64
|
await installHttpRequestAsyncStore();
|
|
66
|
-
improveViteLogs(
|
|
65
|
+
improveViteLogs(config);
|
|
67
66
|
}
|
|
68
|
-
logDockerHint(
|
|
67
|
+
logDockerHint(config.server.host);
|
|
69
68
|
}
|
|
70
69
|
},
|
|
71
70
|
{
|
|
@@ -76,7 +75,6 @@ function devConfig() {
|
|
|
76
75
|
configureServer: {
|
|
77
76
|
order: 'post',
|
|
78
77
|
handler(server) {
|
|
79
|
-
const config = getResolvedConfig(server?.config, vite5Config);
|
|
80
78
|
const hasHonoViteDevServer = !!config.plugins.find((p) => p.name === '@hono/vite-dev-server');
|
|
81
79
|
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
82
80
|
return;
|
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import MagicString from 'magic-string';
|
|
2
1
|
export { envVarsPlugin };
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
3
|
import { loadEnv } from 'vite';
|
|
4
4
|
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, lowerFirst } from '../utils.js';
|
|
5
5
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
7
|
import { isViteServerBuild_safe } from '../shared/isViteServerBuild.js';
|
|
8
|
-
import { getResolvedConfig } from '../shared/getResolvedConfig.js';
|
|
9
8
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
10
9
|
// - Make import.meta.env work inside +config.js
|
|
11
10
|
// - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
|
|
12
11
|
// - Or stop using Vite's `mode` implemention and have Vike implement its own `mode` feature? (So that the only dependencies are `$ vike build --mode staging` and `$ MODE=staging vike build`.)
|
|
13
12
|
const PUBLIC_ENV_PREFIX = 'PUBLIC_ENV__';
|
|
14
|
-
const
|
|
13
|
+
const PUBLIC_ENV_ALLOWLIST = [
|
|
15
14
|
// https://github.com/vikejs/vike/issues/1724
|
|
16
15
|
'STORYBOOK'
|
|
17
16
|
];
|
|
18
17
|
function envVarsPlugin() {
|
|
19
18
|
let envsAll;
|
|
20
|
-
let
|
|
19
|
+
let config;
|
|
21
20
|
return {
|
|
22
21
|
name: 'vike:envVars',
|
|
23
22
|
enforce: 'post',
|
|
24
23
|
configResolved(config_) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
envsAll = loadEnv(
|
|
28
|
-
|
|
24
|
+
config = config_;
|
|
25
|
+
config.command;
|
|
26
|
+
envsAll = loadEnv(config.mode, config.envDir || config.root, '');
|
|
27
|
+
config.plugins.sort(lowerFirst((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
|
|
29
28
|
},
|
|
30
29
|
transform(code, id, options) {
|
|
31
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
32
30
|
id = normalizeId(id);
|
|
33
31
|
assertPosixPath(id);
|
|
34
32
|
if (id.includes('/node_modules/'))
|
|
@@ -52,7 +50,7 @@ function envVarsPlugin() {
|
|
|
52
50
|
const envStatementRegExStr = escapeRegex(envStatement) + '\\b';
|
|
53
51
|
// Security check
|
|
54
52
|
{
|
|
55
|
-
const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !
|
|
53
|
+
const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !PUBLIC_ENV_ALLOWLIST.includes(envName);
|
|
56
54
|
if (isPrivate && isClientSide) {
|
|
57
55
|
if (!new RegExp(envStatementRegExStr).test(code))
|
|
58
56
|
return;
|
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
// - This is needed for HTML-only pages, and React Server Components.
|
|
5
5
|
// - We recommend using the debug flag to get an idea of how this plugin works: `$ DEBUG=vike:extractAssets pnpm exec vike build`. Then have a look at `dist/client/manifest.json` and see how `.page.server.js` entries have zero JavaScript but only CSS.
|
|
6
6
|
// - This appraoch supports import path aliases `vite.config.js#resolve.alias` https://vitejs.dev/config/#resolve-alias
|
|
7
|
-
import { getResolvedConfig } from '../shared/getResolvedConfig.js';
|
|
8
7
|
export { extractAssetsPlugin };
|
|
9
8
|
export { extractAssetsRE };
|
|
10
|
-
import { assert, assertPosixPath, styleFileRE, createDebugger, isScriptFile, assertUsage } from '../utils.js';
|
|
9
|
+
import { assert, assertPosixPath, styleFileRE, createDebugger, isScriptFile, assertUsage, rollupSourceMapRemove } from '../utils.js';
|
|
11
10
|
import { resolveVirtualFileId, isVirtualFileId, getVirtualFileId } from '../../shared/virtual-files.js';
|
|
12
11
|
import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
13
12
|
import { isAsset } from '../shared/isAsset.js';
|
|
14
13
|
import { getImportStatements } from '../shared/parseEsModule.js';
|
|
15
|
-
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
16
14
|
import pc from '@brillout/picocolors';
|
|
17
15
|
import { handleAssetsManifest_isFixEnabled } from './build/handleAssetsManifest.js';
|
|
18
16
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
@@ -25,7 +23,7 @@ const urlRE = /(\?|&)url(?:&|$)/;
|
|
|
25
23
|
const EMPTY_MODULE_ID = 'virtual:vike:empty-module';
|
|
26
24
|
const debug = createDebugger('vike:extractAssets');
|
|
27
25
|
function extractAssetsPlugin() {
|
|
28
|
-
let
|
|
26
|
+
let config;
|
|
29
27
|
let vikeConfig;
|
|
30
28
|
let isFixEnabled;
|
|
31
29
|
return [
|
|
@@ -36,7 +34,6 @@ function extractAssetsPlugin() {
|
|
|
36
34
|
apply: 'build',
|
|
37
35
|
enforce: 'post',
|
|
38
36
|
async transform(src, id, options) {
|
|
39
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
40
37
|
id = normalizeId(id);
|
|
41
38
|
if (!extractAssetsRE.test(id)) {
|
|
42
39
|
return;
|
|
@@ -53,7 +50,7 @@ function extractAssetsPlugin() {
|
|
|
53
50
|
const moduleNames = getImportedModules(importStatements);
|
|
54
51
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
55
52
|
debugTransformResult(id, code, importStatements);
|
|
56
|
-
return
|
|
53
|
+
return rollupSourceMapRemove(code);
|
|
57
54
|
}
|
|
58
55
|
},
|
|
59
56
|
// This plugin appends `?extractAssets` to module IDs
|
|
@@ -65,7 +62,6 @@ function extractAssetsPlugin() {
|
|
|
65
62
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
66
63
|
enforce: 'pre',
|
|
67
64
|
async resolveId(source, importer, options) {
|
|
68
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
69
65
|
if (isViteServerBuild_safe(config, options)) {
|
|
70
66
|
// When building for the server, there should never be a `?extractAssets` query
|
|
71
67
|
assert(!extractAssetsRE.test(source));
|
|
@@ -141,12 +137,12 @@ function extractAssetsPlugin() {
|
|
|
141
137
|
{
|
|
142
138
|
name: 'vike:extractAssets-4',
|
|
143
139
|
async configResolved(config_) {
|
|
144
|
-
|
|
145
|
-
vikeConfig = await getVikeConfig(
|
|
146
|
-
isFixEnabled = handleAssetsManifest_isFixEnabled(
|
|
140
|
+
config = config_;
|
|
141
|
+
vikeConfig = await getVikeConfig(config);
|
|
142
|
+
isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
147
143
|
if (!isFixEnabled) {
|
|
148
144
|
// https://github.com/vikejs/vike/issues/1060
|
|
149
|
-
assertUsage(!
|
|
145
|
+
assertUsage(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { extractExportNamesPlugin };
|
|
2
2
|
export { isUsingClientRouter };
|
|
3
3
|
export { extractExportNamesRE };
|
|
4
|
-
import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage } from '../utils.js';
|
|
4
|
+
import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage, rollupSourceMapRemove } from '../utils.js';
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
|
-
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
7
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
8
7
|
import { isViteServerBuild_options } from '../shared/isViteServerBuild.js';
|
|
9
8
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
@@ -39,7 +38,7 @@ async function getExtractExportNamesCode(src, isClientSide, isProduction, id) {
|
|
|
39
38
|
globalObject.usesClientRouter = true;
|
|
40
39
|
}
|
|
41
40
|
const code = getCode(exportNames, wildcardReExports, isClientSide, isProduction, id);
|
|
42
|
-
return
|
|
41
|
+
return rollupSourceMapRemove(code);
|
|
43
42
|
}
|
|
44
43
|
function getCode(exportNames, wildcardReExports, isClientSide, isProduction, id) {
|
|
45
44
|
let code = '';
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import { getResolvedConfig } from '../shared/getResolvedConfig.js';
|
|
2
1
|
export { fileEnv };
|
|
3
|
-
import { assert, assertUsage, assertWarning, capitalizeFirstLetter, joinEnglish } from '../utils.js';
|
|
2
|
+
import { assert, assertUsage, assertWarning, capitalizeFirstLetter, joinEnglish, rollupSourceMapRemove } from '../utils.js';
|
|
4
3
|
import { extractAssetsRE } from './extractAssetsPlugin.js';
|
|
5
4
|
import { extractExportNamesRE } from './extractExportNamesPlugin.js';
|
|
6
5
|
import pc from '@brillout/picocolors';
|
|
7
6
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
8
|
-
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
9
7
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
10
8
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
11
9
|
import { isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
12
10
|
function fileEnv() {
|
|
13
|
-
let
|
|
11
|
+
let config;
|
|
14
12
|
let viteDevServer;
|
|
15
13
|
return {
|
|
16
14
|
name: 'vike:fileEnv',
|
|
17
15
|
load(id, options) {
|
|
18
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
19
16
|
// In build, we use generateBundle() instead of the load() hook. Using load() works for dynamic imports in dev thanks to Vite's lazy transpiling, but it doesn't work in build because Rollup transpiles any dynamically imported module even if it's never actually imported.
|
|
20
17
|
if (!viteDevServer)
|
|
21
18
|
return;
|
|
22
19
|
if (!isV1Design(config))
|
|
23
20
|
return;
|
|
24
|
-
if (skip(
|
|
21
|
+
if (skip(id))
|
|
25
22
|
return;
|
|
26
23
|
// For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
|
|
27
24
|
if (id.endsWith('?direct'))
|
|
@@ -31,36 +28,34 @@ function fileEnv() {
|
|
|
31
28
|
const importers = Array.from(moduleInfo.importers)
|
|
32
29
|
.map((m) => m.id)
|
|
33
30
|
.filter((id) => id !== null);
|
|
34
|
-
assertFileEnv(
|
|
31
|
+
assertFileEnv(id, !!options?.ssr, importers,
|
|
35
32
|
// In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
|
|
36
33
|
true);
|
|
37
34
|
},
|
|
38
35
|
// In production, we have to use transform() to replace modules with a runtime error because generateBundle() doesn't work for dynamic imports. In production, dynamic imports can only be verified at runtime.
|
|
39
36
|
async transform(code, id, options) {
|
|
40
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
41
37
|
id = normalizeId(id);
|
|
42
38
|
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
43
39
|
if (viteDevServer)
|
|
44
40
|
return;
|
|
45
|
-
if (skip(
|
|
41
|
+
if (skip(id))
|
|
46
42
|
return;
|
|
47
43
|
const isServerSide = !!options?.ssr;
|
|
48
44
|
if (!isWrongEnv(id, isServerSide))
|
|
49
45
|
return;
|
|
50
46
|
const { importers } = this.getModuleInfo(id);
|
|
51
47
|
// Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code splitted.
|
|
52
|
-
const errMsg = getErrorMessage(
|
|
48
|
+
const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
|
|
53
49
|
// We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
|
|
54
50
|
const { exportNames } = await getExportNames(code);
|
|
55
|
-
return
|
|
51
|
+
return rollupSourceMapRemove([
|
|
56
52
|
`throw new Error(${JSON.stringify(errMsg)});`,
|
|
57
53
|
...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`)
|
|
58
54
|
].join('\n'));
|
|
59
55
|
},
|
|
60
56
|
generateBundle() {
|
|
61
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
62
57
|
Array.from(this.getModuleIds())
|
|
63
|
-
.filter((id) => !skip(
|
|
58
|
+
.filter((id) => !skip(id))
|
|
64
59
|
.forEach((moduleId) => {
|
|
65
60
|
const mod = this.getModuleInfo(moduleId);
|
|
66
61
|
const { importers } = mod;
|
|
@@ -71,20 +66,20 @@ function fileEnv() {
|
|
|
71
66
|
*/
|
|
72
67
|
return;
|
|
73
68
|
}
|
|
74
|
-
assertFileEnv(
|
|
69
|
+
assertFileEnv(moduleId, !!config.build.ssr, importers, false);
|
|
75
70
|
});
|
|
76
71
|
},
|
|
77
72
|
configResolved(config_) {
|
|
78
|
-
|
|
73
|
+
config = config_;
|
|
79
74
|
},
|
|
80
75
|
configureServer(viteDevServer_) {
|
|
81
76
|
viteDevServer = viteDevServer_;
|
|
82
77
|
}
|
|
83
78
|
};
|
|
84
|
-
function assertFileEnv(
|
|
79
|
+
function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
|
|
85
80
|
if (!isWrongEnv(moduleId, isServerSide))
|
|
86
81
|
return;
|
|
87
|
-
const errMsg = getErrorMessage(
|
|
82
|
+
const errMsg = getErrorMessage(moduleId, isServerSide, importers, onlyWarn, false);
|
|
88
83
|
if (onlyWarn) {
|
|
89
84
|
assertWarning(false, errMsg, { onlyOnce: true });
|
|
90
85
|
}
|
|
@@ -92,7 +87,7 @@ function fileEnv() {
|
|
|
92
87
|
assertUsage(false, errMsg);
|
|
93
88
|
}
|
|
94
89
|
}
|
|
95
|
-
function getErrorMessage(
|
|
90
|
+
function getErrorMessage(moduleId, isServerSide, importers, onlyWarn, noColor) {
|
|
96
91
|
const modulePath = getModulePath(moduleId);
|
|
97
92
|
const envActual = isServerSide ? 'server' : 'client';
|
|
98
93
|
const envExpect = isServerSide ? 'client' : 'server';
|
|
@@ -117,7 +112,7 @@ function fileEnv() {
|
|
|
117
112
|
const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
|
|
118
113
|
return modulePath.includes(suffixWrong);
|
|
119
114
|
}
|
|
120
|
-
function skip(
|
|
115
|
+
function skip(id) {
|
|
121
116
|
// TODO/v1-release: remove
|
|
122
117
|
if (extractAssetsRE.test(id) || extractExportNamesRE.test(id))
|
|
123
118
|
return true;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getResolvedConfig } from '../../shared/getResolvedConfig.js';
|
|
2
1
|
export { importUserCode };
|
|
3
2
|
import { normalizePath } from 'vite';
|
|
4
3
|
import { getVirtualFilePageConfigValuesAll } from './v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js';
|
|
@@ -14,16 +13,16 @@ import { getModuleFilePathAbsolute } from '../../shared/getFilePath.js';
|
|
|
14
13
|
import { updateUserFiles } from '../../../runtime/globalContext.js';
|
|
15
14
|
import { isPlusFile } from './v1-design/getVikeConfig/crawlPlusFiles.js';
|
|
16
15
|
function importUserCode() {
|
|
17
|
-
let
|
|
16
|
+
let config;
|
|
18
17
|
let vikeConfig;
|
|
19
18
|
return {
|
|
20
19
|
name: 'vike:importUserCode',
|
|
21
20
|
async configResolved(config_) {
|
|
22
21
|
vikeConfig = await getVikeConfig(config_);
|
|
23
|
-
|
|
22
|
+
config = config_;
|
|
24
23
|
// TODO/v1-release: remove
|
|
25
|
-
if (!isV1Design(
|
|
26
|
-
|
|
24
|
+
if (!isV1Design(config))
|
|
25
|
+
config.experimental.importGlobRestoreExtension = true;
|
|
27
26
|
},
|
|
28
27
|
resolveId(id) {
|
|
29
28
|
if (isVirtualFileId(id)) {
|
|
@@ -32,7 +31,7 @@ function importUserCode() {
|
|
|
32
31
|
},
|
|
33
32
|
async handleHotUpdate(ctx) {
|
|
34
33
|
try {
|
|
35
|
-
return await handleHotUpdate(ctx,
|
|
34
|
+
return await handleHotUpdate(ctx, config);
|
|
36
35
|
}
|
|
37
36
|
catch (err) {
|
|
38
37
|
// Vite swallows errors thrown by handleHotUpdate()
|
|
@@ -41,7 +40,6 @@ function importUserCode() {
|
|
|
41
40
|
}
|
|
42
41
|
},
|
|
43
42
|
async load(id, options) {
|
|
44
|
-
const config = getResolvedConfig(this.environment?.config, vite5Config);
|
|
45
43
|
if (!isVirtualFileId(id))
|
|
46
44
|
return undefined;
|
|
47
45
|
id = getVirtualFileId(id);
|
|
@@ -57,7 +55,7 @@ function importUserCode() {
|
|
|
57
55
|
}
|
|
58
56
|
},
|
|
59
57
|
configureServer(server) {
|
|
60
|
-
handleFileAddRemove(server,
|
|
58
|
+
handleFileAddRemove(server, config);
|
|
61
59
|
}
|
|
62
60
|
};
|
|
63
61
|
}
|
|
@@ -67,7 +67,7 @@ async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
|
67
67
|
if (hasProp(hookReturn.pageContext, 'urlLogical')) {
|
|
68
68
|
assertUsageUrlPathnameAbsolute(
|
|
69
69
|
// We skip validation and type-cast instead of assertUsage() in order to save client-side KBs
|
|
70
|
-
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${pc.cyan('{ pageContext: { urlLogical } }')}
|
|
70
|
+
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${pc.cyan('{ pageContext: { urlLogical } }')} and ${pc.cyan('urlLogical')}`);
|
|
71
71
|
}
|
|
72
72
|
assertPageContextProvidedByUser(hookReturn.pageContext, {
|
|
73
73
|
hookFilePath: onBeforeRouteHook.hookFilePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.227-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.227-commit-e36b916";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.227-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.227-commit-e36b916';
|
|
@@ -7,12 +7,12 @@ import { assert } from './assert.js';
|
|
|
7
7
|
// We can't use a RegExp:
|
|
8
8
|
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
9
9
|
// - Vite's `import.meta.glob()` uses Micromatch
|
|
10
|
-
// - We need this to be a
|
|
10
|
+
// - We need this to be a allowlist because:
|
|
11
11
|
// - A pattern `*([a-zA-Z0-9]` doesn't work.
|
|
12
12
|
// - Because of ReScript: `.res` are ReScript source files which need to be ignored. (The ReScript compiler generates `.js` files alongside `.res` files.)
|
|
13
|
-
// -
|
|
14
|
-
// - We cannot implement a
|
|
15
|
-
// - A post `import.meta.glob()`
|
|
13
|
+
// - Block listing doesn't work.
|
|
14
|
+
// - We cannot implement a blocklist with a glob pattern.
|
|
15
|
+
// - A post `import.meta.glob()` blocklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
|
|
16
16
|
// prettier-ignore
|
|
17
17
|
// biome-ignore format:
|
|
18
18
|
const extJavaScript = [
|
|
@@ -182,14 +182,14 @@ function parseProtocol(uri) {
|
|
|
182
182
|
return { protocol, uriWithoutProtocol };
|
|
183
183
|
}
|
|
184
184
|
function isUrlProtocol(protocol) {
|
|
185
|
-
// Is there an
|
|
186
|
-
// - If the
|
|
187
|
-
const
|
|
185
|
+
// Is there an alternative to having a blocklist?
|
|
186
|
+
// - If the blocklist becomes too big, maybe use a allowlist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
|
|
187
|
+
const blocklist = [
|
|
188
188
|
// https://docs.ipfs.tech/how-to/address-ipfs-on-web
|
|
189
189
|
'ipfs://',
|
|
190
190
|
'ipns://'
|
|
191
191
|
];
|
|
192
|
-
if (
|
|
192
|
+
if (blocklist.includes(protocol))
|
|
193
193
|
return false;
|
|
194
194
|
return protocol.endsWith('://');
|
|
195
195
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { rollupSourceMapRemove };
|
|
2
|
+
export { rollupSourceMapPassthrough };
|
|
3
3
|
/** Remove entire source mapping, to save KBs. */
|
|
4
|
-
declare function
|
|
4
|
+
declare function rollupSourceMapRemove(code: string): {
|
|
5
5
|
code: string;
|
|
6
6
|
map: {
|
|
7
7
|
mappings: '';
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
/** Don't provide any source map, pass through current source map instead. */
|
|
11
|
-
declare function
|
|
11
|
+
declare function rollupSourceMapPassthrough(code: string): {
|
|
12
12
|
code: string;
|
|
13
13
|
map: null;
|
|
14
14
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { rollupSourceMapRemove };
|
|
2
|
+
export { rollupSourceMapPassthrough };
|
|
3
3
|
// https://rollupjs.org/guide/en/#source-code-transformations
|
|
4
4
|
/** Remove entire source mapping, to save KBs. */
|
|
5
|
-
function
|
|
5
|
+
function rollupSourceMapRemove(code) {
|
|
6
6
|
return {
|
|
7
7
|
code,
|
|
8
8
|
map: { mappings: '' }
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
/** Don't provide any source map, pass through current source map instead. */
|
|
12
|
-
function
|
|
12
|
+
function rollupSourceMapPassthrough(code) {
|
|
13
13
|
return {
|
|
14
14
|
code,
|
|
15
15
|
map: null
|
package/package.json
CHANGED