vike 0.4.199-commit-29f9afc → 0.4.199-commit-749c7bd
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/envVars.js +3 -0
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +2 -0
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -0
- package/dist/cjs/node/plugin/plugins/fileEnv.js +2 -0
- package/dist/cjs/node/plugin/shared/normalizeId.js +9 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/envVars.js +3 -0
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -0
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -0
- package/dist/esm/node/plugin/plugins/fileEnv.js +2 -0
- package/dist/esm/node/plugin/shared/normalizeId.d.ts +2 -0
- package/dist/esm/node/plugin/shared/normalizeId.js +7 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const vite_1 = require("vite");
|
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
7
7
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
8
|
+
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
8
9
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
9
10
|
// - Make import.meta.env work inside +config.js
|
|
10
11
|
// - 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
|
|
@@ -27,9 +28,11 @@ function envVarsPlugin() {
|
|
|
27
28
|
config.plugins.sort((0, utils_js_1.lowerFirst)((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
|
|
28
29
|
},
|
|
29
30
|
transform(code, id, options) {
|
|
31
|
+
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
30
32
|
(0, utils_js_1.assertPosixPath)(id);
|
|
31
33
|
if (id.includes('/node_modules/'))
|
|
32
34
|
return;
|
|
35
|
+
(0, utils_js_1.assertPosixPath)(config.root);
|
|
33
36
|
if (!id.startsWith(config.root))
|
|
34
37
|
return;
|
|
35
38
|
if (!code.includes('import.meta.env.'))
|
|
@@ -17,6 +17,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
17
17
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
18
18
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
19
19
|
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
20
|
+
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
20
21
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
21
22
|
exports.extractAssetsRE = extractAssetsRE;
|
|
22
23
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
@@ -36,6 +37,7 @@ function extractAssetsPlugin() {
|
|
|
36
37
|
apply: 'build',
|
|
37
38
|
enforce: 'post',
|
|
38
39
|
async transform(src, id, options) {
|
|
40
|
+
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
39
41
|
if (!extractAssetsRE.test(id)) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
@@ -6,6 +6,7 @@ exports.isUsingClientRouter = isUsingClientRouter;
|
|
|
6
6
|
const utils_js_1 = require("../utils.js");
|
|
7
7
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
8
8
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
9
|
+
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
9
10
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
10
11
|
exports.extractExportNamesRE = extractExportNamesRE;
|
|
11
12
|
const debug = (0, utils_js_1.createDebugger)('vike:extractExportNames');
|
|
@@ -16,6 +17,7 @@ function extractExportNamesPlugin() {
|
|
|
16
17
|
name: 'vike:extractExportNames',
|
|
17
18
|
enforce: 'post',
|
|
18
19
|
async transform(src, id, options) {
|
|
20
|
+
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
19
21
|
const isClientSide = !(0, utils_js_1.viteIsSSR_options)(options);
|
|
20
22
|
if (extractExportNamesRE.test(id)) {
|
|
21
23
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
@@ -11,6 +11,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
11
11
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
12
12
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
13
13
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
14
|
+
const normalizeId_js_1 = require("../shared/normalizeId.js");
|
|
14
15
|
function fileEnv() {
|
|
15
16
|
let config;
|
|
16
17
|
let viteDevServer;
|
|
@@ -36,6 +37,7 @@ function fileEnv() {
|
|
|
36
37
|
},
|
|
37
38
|
// 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.
|
|
38
39
|
async transform(code, id, options) {
|
|
40
|
+
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
39
41
|
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
40
42
|
if (viteDevServer)
|
|
41
43
|
return;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeId = normalizeId;
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
// In principle Vite/Rollup should always normalize the `id` in `transform(code, id)` but it seems to not always do it.
|
|
6
|
+
// https://github.com/vikejs/vike/issues/1935
|
|
7
|
+
function normalizeId(id) {
|
|
8
|
+
return (0, utils_js_1.toPosixPath)(id);
|
|
9
|
+
}
|
|
@@ -3,6 +3,7 @@ import { loadEnv } from 'vite';
|
|
|
3
3
|
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, lowerFirst } from '../utils.js';
|
|
4
4
|
import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
|
|
5
5
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
6
|
+
import { normalizeId } from '../shared/normalizeId.js';
|
|
6
7
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
7
8
|
// - Make import.meta.env work inside +config.js
|
|
8
9
|
// - 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
|
|
@@ -25,9 +26,11 @@ function envVarsPlugin() {
|
|
|
25
26
|
config.plugins.sort(lowerFirst((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
|
|
26
27
|
},
|
|
27
28
|
transform(code, id, options) {
|
|
29
|
+
id = normalizeId(id);
|
|
28
30
|
assertPosixPath(id);
|
|
29
31
|
if (id.includes('/node_modules/'))
|
|
30
32
|
return;
|
|
33
|
+
assertPosixPath(config.root);
|
|
31
34
|
if (!id.startsWith(config.root))
|
|
32
35
|
return;
|
|
33
36
|
if (!code.includes('import.meta.env.'))
|
|
@@ -16,6 +16,7 @@ import pc from '@brillout/picocolors';
|
|
|
16
16
|
import { fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
17
17
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
18
18
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
19
|
+
import { normalizeId } from '../shared/normalizeId.js';
|
|
19
20
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
20
21
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
21
22
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
@@ -34,6 +35,7 @@ function extractAssetsPlugin() {
|
|
|
34
35
|
apply: 'build',
|
|
35
36
|
enforce: 'post',
|
|
36
37
|
async transform(src, id, options) {
|
|
38
|
+
id = normalizeId(id);
|
|
37
39
|
if (!extractAssetsRE.test(id)) {
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
@@ -4,6 +4,7 @@ export { extractExportNamesRE };
|
|
|
4
4
|
import { assert, getFileExtension, viteIsSSR_options, createDebugger, getGlobalObject, assertUsage } from '../utils.js';
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
6
|
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
7
|
+
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
8
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
8
9
|
const debug = createDebugger('vike:extractExportNames');
|
|
9
10
|
const globalObject = getGlobalObject('extractExportNamesPlugin.ts', {});
|
|
@@ -13,6 +14,7 @@ function extractExportNamesPlugin() {
|
|
|
13
14
|
name: 'vike:extractExportNames',
|
|
14
15
|
enforce: 'post',
|
|
15
16
|
async transform(src, id, options) {
|
|
17
|
+
id = normalizeId(id);
|
|
16
18
|
const isClientSide = !viteIsSSR_options(options);
|
|
17
19
|
if (extractExportNamesRE.test(id)) {
|
|
18
20
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
@@ -6,6 +6,7 @@ import pc from '@brillout/picocolors';
|
|
|
6
6
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
7
7
|
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
8
8
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
9
|
+
import { normalizeId } from '../shared/normalizeId.js';
|
|
9
10
|
function fileEnv() {
|
|
10
11
|
let config;
|
|
11
12
|
let viteDevServer;
|
|
@@ -31,6 +32,7 @@ function fileEnv() {
|
|
|
31
32
|
},
|
|
32
33
|
// 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.
|
|
33
34
|
async transform(code, id, options) {
|
|
35
|
+
id = normalizeId(id);
|
|
34
36
|
// In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
|
|
35
37
|
if (viteDevServer)
|
|
36
38
|
return;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { normalizeId };
|
|
2
|
+
import { toPosixPath } from '../utils.js';
|
|
3
|
+
// In principle Vite/Rollup should always normalize the `id` in `transform(code, id)` but it seems to not always do it.
|
|
4
|
+
// https://github.com/vikejs/vike/issues/1935
|
|
5
|
+
function normalizeId(id) {
|
|
6
|
+
return toPosixPath(id);
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.199-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.199-commit-749c7bd";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.199-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.199-commit-749c7bd';
|