@qwik.dev/core 2.0.0-beta.8 → 2.0.0-beta.9
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/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/index.cjs +6 -0
- package/dist/backpatch/index.d.ts +2 -0
- package/dist/backpatch/index.mjs +5 -0
- package/dist/backpatch/package.json +8 -0
- package/dist/backpatch-executor.debug.js +34 -0
- package/dist/backpatch-executor.js +1 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +105 -55
- package/dist/core.cjs +976 -456
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +974 -456
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +638 -351
- package/dist/core.prod.mjs +709 -362
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +75 -73
- package/dist/optimizer.mjs +75 -75
- package/dist/server.cjs +143 -42
- package/dist/server.d.ts +9 -0
- package/dist/server.mjs +140 -42
- package/dist/testing/index.cjs +3749 -927
- package/dist/testing/index.d.ts +972 -1
- package/dist/testing/index.mjs +3735 -921
- package/dist/testing/package.json +1 -1
- package/package.json +4 -2
package/dist/loader/package.json
CHANGED
package/dist/optimizer.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/optimizer 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/optimizer 2.0.0-beta.9-dev+6b582c7
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -1257,7 +1257,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
1257
1257
|
}
|
|
1258
1258
|
};
|
|
1259
1259
|
var versions = {
|
|
1260
|
-
qwik: "2.0.0-beta.
|
|
1260
|
+
qwik: "2.0.0-beta.9-dev+6b582c7"
|
|
1261
1261
|
};
|
|
1262
1262
|
async function getSystem() {
|
|
1263
1263
|
const sysEnv = getEnv();
|
|
@@ -3512,7 +3512,6 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3512
3512
|
async config(viteConfig, viteEnv) {
|
|
3513
3513
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
3514
3514
|
await qwikPlugin.init();
|
|
3515
|
-
const sys = qwikPlugin.getSys();
|
|
3516
3515
|
const path = qwikPlugin.getPath();
|
|
3517
3516
|
let target;
|
|
3518
3517
|
target = (null == (_a = viteConfig.build) ? void 0 : _a.ssr) || "ssr" === viteEnv.mode ? "ssr" : "lib" === viteEnv.mode ? "lib" : "test" === viteEnv.mode ? "test" : "client";
|
|
@@ -3532,7 +3531,6 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3532
3531
|
const clientInput = "client" === target ? null == (_d = qwikViteOpts.client) ? void 0 : _d.input : void 0;
|
|
3533
3532
|
let input = (null == (_f = null == (_e = viteConfig.build) ? void 0 : _e.rollupOptions) ? void 0 : _f.input) || clientInput || ssrInput;
|
|
3534
3533
|
input && "string" === typeof input && (input = [ input ]);
|
|
3535
|
-
const shouldFindVendors = !qwikViteOpts.disableVendorScan && ("lib" !== target || "serve" === viteCommand);
|
|
3536
3534
|
viteAssetsDir = null == (_g = viteConfig.build) ? void 0 : _g.assetsDir;
|
|
3537
3535
|
const useAssetsDir = "client" === target && !!viteAssetsDir && "_astro" !== viteAssetsDir;
|
|
3538
3536
|
const pluginOpts = {
|
|
@@ -3570,8 +3568,6 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3570
3568
|
clientDevInput = "string" === typeof (null == (_q = qwikViteOpts.client) ? void 0 : _q.devInput) ? path.resolve(opts.rootDir, qwikViteOpts.client.devInput) : opts.srcDir ? path.resolve(opts.srcDir, CLIENT_DEV_INPUT) : path.resolve(opts.rootDir, "src", CLIENT_DEV_INPUT);
|
|
3571
3569
|
clientDevInput = qwikPlugin.normalizePath(clientDevInput);
|
|
3572
3570
|
}
|
|
3573
|
-
const vendorRoots = shouldFindVendors ? await findQwikRoots(sys, sys.cwd()) : [];
|
|
3574
|
-
const vendorIds = vendorRoots.map(v => v.id);
|
|
3575
3571
|
const isDevelopment = "development" === buildMode;
|
|
3576
3572
|
const qDevKey = "globalThis.qDev";
|
|
3577
3573
|
const qTestKey = "globalThis.qTest";
|
|
@@ -3582,11 +3578,11 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3582
3578
|
const qSerialize = (null == (_t = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _t[qSerializeKey]) ?? isDevelopment;
|
|
3583
3579
|
const updatedViteConfig = {
|
|
3584
3580
|
ssr: {
|
|
3585
|
-
noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID
|
|
3581
|
+
noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID ]
|
|
3586
3582
|
},
|
|
3587
3583
|
envPrefix: [ "VITE_", "PUBLIC_" ],
|
|
3588
3584
|
resolve: {
|
|
3589
|
-
dedupe: [ ...DEDUPE
|
|
3585
|
+
dedupe: [ ...DEDUPE ],
|
|
3590
3586
|
conditions: "production" === buildMode && "client" === target ? [ "min" ] : [],
|
|
3591
3587
|
alias: {
|
|
3592
3588
|
"@builder.io/qwik": "@qwik.dev/core",
|
|
@@ -3597,6 +3593,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3597
3593
|
"@builder.io/qwik/jsx-dev-runtime": "@qwik.dev/core/jsx-dev-runtime",
|
|
3598
3594
|
"@builder.io/qwik/optimizer": "@qwik.dev/core/optimizer",
|
|
3599
3595
|
"@builder.io/qwik/loader": "@qwik.dev/core/loader",
|
|
3596
|
+
"@builder.io/qwik/backpatch": "@qwik.dev/core/backpatch",
|
|
3600
3597
|
"@builder.io/qwik/cli": "@qwik.dev/core/cli",
|
|
3601
3598
|
"@builder.io/qwik/testing": "@qwik.dev/core/testing"
|
|
3602
3599
|
}
|
|
@@ -3606,7 +3603,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3606
3603
|
jsx: "automatic"
|
|
3607
3604
|
},
|
|
3608
3605
|
optimizeDeps: {
|
|
3609
|
-
exclude: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_JSX_RUNTIME_ID, QWIK_JSX_DEV_RUNTIME_ID, QWIK_BUILD_ID, QWIK_CLIENT_MANIFEST_ID,
|
|
3606
|
+
exclude: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_JSX_RUNTIME_ID, QWIK_JSX_DEV_RUNTIME_ID, QWIK_BUILD_ID, QWIK_CLIENT_MANIFEST_ID, "@builder.io/qwik", "@builder.io/qwik-city" ]
|
|
3610
3607
|
},
|
|
3611
3608
|
build: {
|
|
3612
3609
|
modulePreload: false,
|
|
@@ -3850,7 +3847,75 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3850
3847
|
}
|
|
3851
3848
|
}
|
|
3852
3849
|
};
|
|
3853
|
-
return [ vitePluginPre, vitePluginPost ];
|
|
3850
|
+
return [ vitePluginPre, vitePluginPost, checkExternals() ];
|
|
3851
|
+
}
|
|
3852
|
+
async function checkExternals() {
|
|
3853
|
+
let fs;
|
|
3854
|
+
let path;
|
|
3855
|
+
try {
|
|
3856
|
+
fs = await import("node:fs").then(m => m.promises);
|
|
3857
|
+
path = await import("node:path");
|
|
3858
|
+
} catch {
|
|
3859
|
+
return;
|
|
3860
|
+
}
|
|
3861
|
+
const seen = new Set;
|
|
3862
|
+
let rootDir;
|
|
3863
|
+
const core2 = "@qwik-dev/core";
|
|
3864
|
+
const core1 = "@builder.io/qwik";
|
|
3865
|
+
async function isQwikDep(dep, dir) {
|
|
3866
|
+
var _a, _b, _c, _d;
|
|
3867
|
+
while (dir) {
|
|
3868
|
+
const pkg = path.join(dir, "node_modules", dep, "package.json");
|
|
3869
|
+
try {
|
|
3870
|
+
await fs.access(pkg);
|
|
3871
|
+
const data = await fs.readFile(pkg, {
|
|
3872
|
+
encoding: "utf-8"
|
|
3873
|
+
});
|
|
3874
|
+
const json = JSON.parse(data);
|
|
3875
|
+
if (json.qwik || (null == (_a = json.dependencies) ? void 0 : _a[core2]) || (null == (_b = json.peerDependencies) ? void 0 : _b[core2]) || (null == (_c = json.dependencies) ? void 0 : _c[core1]) || (null == (_d = json.peerDependencies) ? void 0 : _d[core1])) {
|
|
3876
|
+
return true;
|
|
3877
|
+
}
|
|
3878
|
+
return false;
|
|
3879
|
+
} catch {}
|
|
3880
|
+
const nextRoot = path.dirname(dir);
|
|
3881
|
+
if (nextRoot === dir) {
|
|
3882
|
+
break;
|
|
3883
|
+
}
|
|
3884
|
+
dir = nextRoot;
|
|
3885
|
+
}
|
|
3886
|
+
return false;
|
|
3887
|
+
}
|
|
3888
|
+
return {
|
|
3889
|
+
name: "checkQwikExternals",
|
|
3890
|
+
enforce: "pre",
|
|
3891
|
+
configResolved: config => {
|
|
3892
|
+
rootDir = config.root;
|
|
3893
|
+
},
|
|
3894
|
+
resolveId: {
|
|
3895
|
+
order: "pre",
|
|
3896
|
+
async handler(source, importer, options) {
|
|
3897
|
+
if (!options.ssr || /^([./]|node:|[^a-z])/.test(source) || seen.has(source)) {
|
|
3898
|
+
return;
|
|
3899
|
+
}
|
|
3900
|
+
const packageName = (source.startsWith("@") ? source.split("/").slice(0, 2).join("/") : source.split("/")[0]).split("?")[0];
|
|
3901
|
+
if (seen.has(packageName)) {
|
|
3902
|
+
return;
|
|
3903
|
+
}
|
|
3904
|
+
seen.add(source);
|
|
3905
|
+
seen.add(packageName);
|
|
3906
|
+
const result = await this.resolve(packageName, importer, {
|
|
3907
|
+
...options,
|
|
3908
|
+
skipSelf: true
|
|
3909
|
+
});
|
|
3910
|
+
if ((null == result ? void 0 : result.external) && await isQwikDep(packageName, importer ? path.dirname(importer) : rootDir)) {
|
|
3911
|
+
throw new Error(`\n==============\n${packageName} is being treated as an external dependency, but it should be included in the server bundle, because it uses Qwik.\nPlease add the package to "ssr.noExternal" in the Vite config. \n==============`);
|
|
3912
|
+
}
|
|
3913
|
+
if (packageName === source) {
|
|
3914
|
+
return result;
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
};
|
|
3854
3919
|
}
|
|
3855
3920
|
var ANSI_COLOR = {
|
|
3856
3921
|
Black: "[30m",
|
|
@@ -3884,69 +3949,6 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3884
3949
|
const qwikLoader = JSON.stringify(opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED);
|
|
3885
3950
|
return `// Qwik Vite Dev Module\nimport { render as qwikRender } from '@qwik.dev/core';\n\nexport async function render(document, rootNode, opts) {\n\n await qwikRender(document, rootNode, opts);\n\n let qwikLoader = document.getElementById('qwikloader');\n if (!qwikLoader) {\n qwikLoader = document.createElement('script');\n qwikLoader.id = 'qwikloader';\n qwikLoader.innerHTML = ${qwikLoader};\n const parent = document.head ?? document.body ?? document.documentElement;\n parent.appendChild(qwikLoader);\n }\n\n if (!window.__qwikViteLog) {\n window.__qwikViteLog = true;\n console.debug("%c⭐️ Qwik Client Mode","background: #0c75d2; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;","Do not use this mode in production!\\n - No portion of the application is pre-rendered on the server\\n - All of the application is running eagerly in the browser\\n - Optimizer/Serialization/Deserialization code is not exercised!");\n }\n}`;
|
|
3886
3951
|
}
|
|
3887
|
-
async function findDepPkgJsonPath(sys, dep, parent) {
|
|
3888
|
-
const fs = await sys.dynamicImport("node:fs");
|
|
3889
|
-
let root = parent;
|
|
3890
|
-
while (root) {
|
|
3891
|
-
const pkg = sys.path.join(root, "node_modules", dep, "package.json");
|
|
3892
|
-
try {
|
|
3893
|
-
await fs.promises.access(pkg);
|
|
3894
|
-
return fs.promises.realpath(pkg);
|
|
3895
|
-
} catch {}
|
|
3896
|
-
const nextRoot = sys.path.dirname(root);
|
|
3897
|
-
if (nextRoot === root) {
|
|
3898
|
-
break;
|
|
3899
|
-
}
|
|
3900
|
-
root = nextRoot;
|
|
3901
|
-
}
|
|
3902
|
-
return;
|
|
3903
|
-
}
|
|
3904
|
-
var findQwikRoots = async (sys, packageJsonDir) => {
|
|
3905
|
-
const paths = new Map;
|
|
3906
|
-
if ("node" === sys.env || "bun" === sys.env) {
|
|
3907
|
-
const fs = await sys.dynamicImport("node:fs");
|
|
3908
|
-
let prevPackageJsonDir;
|
|
3909
|
-
do {
|
|
3910
|
-
try {
|
|
3911
|
-
const data = await fs.promises.readFile(sys.path.join(packageJsonDir, "package.json"), {
|
|
3912
|
-
encoding: "utf-8"
|
|
3913
|
-
});
|
|
3914
|
-
try {
|
|
3915
|
-
const packageJson = JSON.parse(data);
|
|
3916
|
-
const dependencies = packageJson.dependencies;
|
|
3917
|
-
const devDependencies = packageJson.devDependencies;
|
|
3918
|
-
const packages = [];
|
|
3919
|
-
"object" === typeof dependencies && packages.push(...Object.keys(dependencies));
|
|
3920
|
-
"object" === typeof devDependencies && packages.push(...Object.keys(devDependencies));
|
|
3921
|
-
const basedir = sys.cwd();
|
|
3922
|
-
await Promise.all(packages.map(async id => {
|
|
3923
|
-
const pkgJsonPath = await findDepPkgJsonPath(sys, id, basedir);
|
|
3924
|
-
if (pkgJsonPath) {
|
|
3925
|
-
const pkgJsonContent = await fs.promises.readFile(pkgJsonPath, "utf-8");
|
|
3926
|
-
const pkgJson = JSON.parse(pkgJsonContent);
|
|
3927
|
-
const qwikPath = pkgJson.qwik;
|
|
3928
|
-
if (!qwikPath) {
|
|
3929
|
-
return;
|
|
3930
|
-
}
|
|
3931
|
-
const allPaths = Array.isArray(qwikPath) ? qwikPath : [ qwikPath ];
|
|
3932
|
-
for (const p of allPaths) {
|
|
3933
|
-
paths.set(await fs.promises.realpath(sys.path.resolve(sys.path.dirname(pkgJsonPath), p)), id);
|
|
3934
|
-
}
|
|
3935
|
-
}
|
|
3936
|
-
}));
|
|
3937
|
-
} catch (e) {
|
|
3938
|
-
console.error(e);
|
|
3939
|
-
}
|
|
3940
|
-
} catch {}
|
|
3941
|
-
prevPackageJsonDir = packageJsonDir;
|
|
3942
|
-
packageJsonDir = sys.path.dirname(packageJsonDir);
|
|
3943
|
-
} while (packageJsonDir !== prevPackageJsonDir);
|
|
3944
|
-
}
|
|
3945
|
-
return Array.from(paths).map(([path, id]) => ({
|
|
3946
|
-
path: path,
|
|
3947
|
-
id: id
|
|
3948
|
-
}));
|
|
3949
|
-
};
|
|
3950
3952
|
var VITE_CLIENT_MODULE = "@qwik.dev/core/vite-client";
|
|
3951
3953
|
var CLIENT_DEV_INPUT = "entry.dev";
|
|
3952
3954
|
var symbolMapper = void 0;
|
package/dist/optimizer.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/optimizer 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/optimizer 2.0.0-beta.9-dev+6b582c7
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -1282,7 +1282,7 @@ var QWIK_BINDING_MAP = {
|
|
|
1282
1282
|
};
|
|
1283
1283
|
|
|
1284
1284
|
var versions = {
|
|
1285
|
-
qwik: "2.0.0-beta.
|
|
1285
|
+
qwik: "2.0.0-beta.9-dev+6b582c7"
|
|
1286
1286
|
};
|
|
1287
1287
|
|
|
1288
1288
|
async function getSystem() {
|
|
@@ -3630,7 +3630,6 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3630
3630
|
api: api,
|
|
3631
3631
|
async config(viteConfig, viteEnv) {
|
|
3632
3632
|
await qwikPlugin.init();
|
|
3633
|
-
const sys = qwikPlugin.getSys();
|
|
3634
3633
|
const path = qwikPlugin.getPath();
|
|
3635
3634
|
let target;
|
|
3636
3635
|
target = viteConfig.build?.ssr || "ssr" === viteEnv.mode ? "ssr" : "lib" === viteEnv.mode ? "lib" : "test" === viteEnv.mode ? "test" : "client";
|
|
@@ -3650,7 +3649,6 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3650
3649
|
const clientInput = "client" === target ? qwikViteOpts.client?.input : void 0;
|
|
3651
3650
|
let input = viteConfig.build?.rollupOptions?.input || clientInput || ssrInput;
|
|
3652
3651
|
input && "string" === typeof input && (input = [ input ]);
|
|
3653
|
-
const shouldFindVendors = !qwikViteOpts.disableVendorScan && ("lib" !== target || "serve" === viteCommand);
|
|
3654
3652
|
viteAssetsDir = viteConfig.build?.assetsDir;
|
|
3655
3653
|
const useAssetsDir = "client" === target && !!viteAssetsDir && "_astro" !== viteAssetsDir;
|
|
3656
3654
|
const pluginOpts = {
|
|
@@ -3688,8 +3686,6 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3688
3686
|
clientDevInput = "string" === typeof qwikViteOpts.client?.devInput ? path.resolve(opts.rootDir, qwikViteOpts.client.devInput) : opts.srcDir ? path.resolve(opts.srcDir, CLIENT_DEV_INPUT) : path.resolve(opts.rootDir, "src", CLIENT_DEV_INPUT);
|
|
3689
3687
|
clientDevInput = qwikPlugin.normalizePath(clientDevInput);
|
|
3690
3688
|
}
|
|
3691
|
-
const vendorRoots = shouldFindVendors ? await findQwikRoots(sys, sys.cwd()) : [];
|
|
3692
|
-
const vendorIds = vendorRoots.map(v => v.id);
|
|
3693
3689
|
const isDevelopment = "development" === buildMode;
|
|
3694
3690
|
const qDevKey = "globalThis.qDev";
|
|
3695
3691
|
const qTestKey = "globalThis.qTest";
|
|
@@ -3700,11 +3696,11 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3700
3696
|
const qSerialize = viteConfig?.define?.[qSerializeKey] ?? isDevelopment;
|
|
3701
3697
|
const updatedViteConfig = {
|
|
3702
3698
|
ssr: {
|
|
3703
|
-
noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID
|
|
3699
|
+
noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID ]
|
|
3704
3700
|
},
|
|
3705
3701
|
envPrefix: [ "VITE_", "PUBLIC_" ],
|
|
3706
3702
|
resolve: {
|
|
3707
|
-
dedupe: [ ...DEDUPE
|
|
3703
|
+
dedupe: [ ...DEDUPE ],
|
|
3708
3704
|
conditions: "production" === buildMode && "client" === target ? [ "min" ] : [],
|
|
3709
3705
|
alias: {
|
|
3710
3706
|
"@builder.io/qwik": "@qwik.dev/core",
|
|
@@ -3715,6 +3711,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3715
3711
|
"@builder.io/qwik/jsx-dev-runtime": "@qwik.dev/core/jsx-dev-runtime",
|
|
3716
3712
|
"@builder.io/qwik/optimizer": "@qwik.dev/core/optimizer",
|
|
3717
3713
|
"@builder.io/qwik/loader": "@qwik.dev/core/loader",
|
|
3714
|
+
"@builder.io/qwik/backpatch": "@qwik.dev/core/backpatch",
|
|
3718
3715
|
"@builder.io/qwik/cli": "@qwik.dev/core/cli",
|
|
3719
3716
|
"@builder.io/qwik/testing": "@qwik.dev/core/testing"
|
|
3720
3717
|
}
|
|
@@ -3724,7 +3721,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3724
3721
|
jsx: "automatic"
|
|
3725
3722
|
},
|
|
3726
3723
|
optimizeDeps: {
|
|
3727
|
-
exclude: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_JSX_RUNTIME_ID, QWIK_JSX_DEV_RUNTIME_ID, QWIK_BUILD_ID, QWIK_CLIENT_MANIFEST_ID,
|
|
3724
|
+
exclude: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_JSX_RUNTIME_ID, QWIK_JSX_DEV_RUNTIME_ID, QWIK_BUILD_ID, QWIK_CLIENT_MANIFEST_ID, "@builder.io/qwik", "@builder.io/qwik-city" ]
|
|
3728
3725
|
},
|
|
3729
3726
|
build: {
|
|
3730
3727
|
modulePreload: false,
|
|
@@ -3966,7 +3963,75 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3966
3963
|
}
|
|
3967
3964
|
}
|
|
3968
3965
|
};
|
|
3969
|
-
return [ vitePluginPre, vitePluginPost ];
|
|
3966
|
+
return [ vitePluginPre, vitePluginPost, checkExternals() ];
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
async function checkExternals() {
|
|
3970
|
+
let fs;
|
|
3971
|
+
let path;
|
|
3972
|
+
try {
|
|
3973
|
+
fs = await import("node:fs").then(m => m.promises);
|
|
3974
|
+
path = await import("node:path");
|
|
3975
|
+
} catch {
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3978
|
+
const seen = new Set;
|
|
3979
|
+
let rootDir;
|
|
3980
|
+
const core2 = "@qwik-dev/core";
|
|
3981
|
+
const core1 = "@builder.io/qwik";
|
|
3982
|
+
async function isQwikDep(dep, dir) {
|
|
3983
|
+
while (dir) {
|
|
3984
|
+
const pkg = path.join(dir, "node_modules", dep, "package.json");
|
|
3985
|
+
try {
|
|
3986
|
+
await fs.access(pkg);
|
|
3987
|
+
const data = await fs.readFile(pkg, {
|
|
3988
|
+
encoding: "utf-8"
|
|
3989
|
+
});
|
|
3990
|
+
const json = JSON.parse(data);
|
|
3991
|
+
if (json.qwik || json.dependencies?.[core2] || json.peerDependencies?.[core2] || json.dependencies?.[core1] || json.peerDependencies?.[core1]) {
|
|
3992
|
+
return true;
|
|
3993
|
+
}
|
|
3994
|
+
return false;
|
|
3995
|
+
} catch {}
|
|
3996
|
+
const nextRoot = path.dirname(dir);
|
|
3997
|
+
if (nextRoot === dir) {
|
|
3998
|
+
break;
|
|
3999
|
+
}
|
|
4000
|
+
dir = nextRoot;
|
|
4001
|
+
}
|
|
4002
|
+
return false;
|
|
4003
|
+
}
|
|
4004
|
+
return {
|
|
4005
|
+
name: "checkQwikExternals",
|
|
4006
|
+
enforce: "pre",
|
|
4007
|
+
configResolved: config => {
|
|
4008
|
+
rootDir = config.root;
|
|
4009
|
+
},
|
|
4010
|
+
resolveId: {
|
|
4011
|
+
order: "pre",
|
|
4012
|
+
async handler(source, importer, options) {
|
|
4013
|
+
if (!options.ssr || /^([./]|node:|[^a-z])/.test(source) || seen.has(source)) {
|
|
4014
|
+
return;
|
|
4015
|
+
}
|
|
4016
|
+
const packageName = (source.startsWith("@") ? source.split("/").slice(0, 2).join("/") : source.split("/")[0]).split("?")[0];
|
|
4017
|
+
if (seen.has(packageName)) {
|
|
4018
|
+
return;
|
|
4019
|
+
}
|
|
4020
|
+
seen.add(source);
|
|
4021
|
+
seen.add(packageName);
|
|
4022
|
+
const result = await this.resolve(packageName, importer, {
|
|
4023
|
+
...options,
|
|
4024
|
+
skipSelf: true
|
|
4025
|
+
});
|
|
4026
|
+
if (result?.external && await isQwikDep(packageName, importer ? path.dirname(importer) : rootDir)) {
|
|
4027
|
+
throw new Error(`\n==============\n${packageName} is being treated as an external dependency, but it should be included in the server bundle, because it uses Qwik.\nPlease add the package to "ssr.noExternal" in the Vite config. \n==============`);
|
|
4028
|
+
}
|
|
4029
|
+
if (packageName === source) {
|
|
4030
|
+
return result;
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
};
|
|
3970
4035
|
}
|
|
3971
4036
|
|
|
3972
4037
|
var ANSI_COLOR = {
|
|
@@ -4005,71 +4070,6 @@ function getViteDevModule(opts) {
|
|
|
4005
4070
|
return `// Qwik Vite Dev Module\nimport { render as qwikRender } from '@qwik.dev/core';\n\nexport async function render(document, rootNode, opts) {\n\n await qwikRender(document, rootNode, opts);\n\n let qwikLoader = document.getElementById('qwikloader');\n if (!qwikLoader) {\n qwikLoader = document.createElement('script');\n qwikLoader.id = 'qwikloader';\n qwikLoader.innerHTML = ${qwikLoader};\n const parent = document.head ?? document.body ?? document.documentElement;\n parent.appendChild(qwikLoader);\n }\n\n if (!window.__qwikViteLog) {\n window.__qwikViteLog = true;\n console.debug("%c⭐️ Qwik Client Mode","background: #0c75d2; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;","Do not use this mode in production!\\n - No portion of the application is pre-rendered on the server\\n - All of the application is running eagerly in the browser\\n - Optimizer/Serialization/Deserialization code is not exercised!");\n }\n}`;
|
|
4006
4071
|
}
|
|
4007
4072
|
|
|
4008
|
-
async function findDepPkgJsonPath(sys, dep, parent) {
|
|
4009
|
-
const fs = await sys.dynamicImport("node:fs");
|
|
4010
|
-
let root = parent;
|
|
4011
|
-
while (root) {
|
|
4012
|
-
const pkg = sys.path.join(root, "node_modules", dep, "package.json");
|
|
4013
|
-
try {
|
|
4014
|
-
await fs.promises.access(pkg);
|
|
4015
|
-
return fs.promises.realpath(pkg);
|
|
4016
|
-
} catch {}
|
|
4017
|
-
const nextRoot = sys.path.dirname(root);
|
|
4018
|
-
if (nextRoot === root) {
|
|
4019
|
-
break;
|
|
4020
|
-
}
|
|
4021
|
-
root = nextRoot;
|
|
4022
|
-
}
|
|
4023
|
-
return;
|
|
4024
|
-
}
|
|
4025
|
-
|
|
4026
|
-
var findQwikRoots = async (sys, packageJsonDir) => {
|
|
4027
|
-
const paths = new Map;
|
|
4028
|
-
if ("node" === sys.env || "bun" === sys.env) {
|
|
4029
|
-
const fs = await sys.dynamicImport("node:fs");
|
|
4030
|
-
let prevPackageJsonDir;
|
|
4031
|
-
do {
|
|
4032
|
-
try {
|
|
4033
|
-
const data = await fs.promises.readFile(sys.path.join(packageJsonDir, "package.json"), {
|
|
4034
|
-
encoding: "utf-8"
|
|
4035
|
-
});
|
|
4036
|
-
try {
|
|
4037
|
-
const packageJson = JSON.parse(data);
|
|
4038
|
-
const dependencies = packageJson.dependencies;
|
|
4039
|
-
const devDependencies = packageJson.devDependencies;
|
|
4040
|
-
const packages = [];
|
|
4041
|
-
"object" === typeof dependencies && packages.push(...Object.keys(dependencies));
|
|
4042
|
-
"object" === typeof devDependencies && packages.push(...Object.keys(devDependencies));
|
|
4043
|
-
const basedir = sys.cwd();
|
|
4044
|
-
await Promise.all(packages.map(async id => {
|
|
4045
|
-
const pkgJsonPath = await findDepPkgJsonPath(sys, id, basedir);
|
|
4046
|
-
if (pkgJsonPath) {
|
|
4047
|
-
const pkgJsonContent = await fs.promises.readFile(pkgJsonPath, "utf-8");
|
|
4048
|
-
const pkgJson = JSON.parse(pkgJsonContent);
|
|
4049
|
-
const qwikPath = pkgJson.qwik;
|
|
4050
|
-
if (!qwikPath) {
|
|
4051
|
-
return;
|
|
4052
|
-
}
|
|
4053
|
-
const allPaths = Array.isArray(qwikPath) ? qwikPath : [ qwikPath ];
|
|
4054
|
-
for (const p of allPaths) {
|
|
4055
|
-
paths.set(await fs.promises.realpath(sys.path.resolve(sys.path.dirname(pkgJsonPath), p)), id);
|
|
4056
|
-
}
|
|
4057
|
-
}
|
|
4058
|
-
}));
|
|
4059
|
-
} catch (e) {
|
|
4060
|
-
console.error(e);
|
|
4061
|
-
}
|
|
4062
|
-
} catch {}
|
|
4063
|
-
prevPackageJsonDir = packageJsonDir;
|
|
4064
|
-
packageJsonDir = sys.path.dirname(packageJsonDir);
|
|
4065
|
-
} while (packageJsonDir !== prevPackageJsonDir);
|
|
4066
|
-
}
|
|
4067
|
-
return Array.from(paths).map(([path, id]) => ({
|
|
4068
|
-
path: path,
|
|
4069
|
-
id: id
|
|
4070
|
-
}));
|
|
4071
|
-
};
|
|
4072
|
-
|
|
4073
4073
|
var VITE_CLIENT_MODULE = "@qwik.dev/core/vite-client";
|
|
4074
4074
|
|
|
4075
4075
|
var CLIENT_DEV_INPUT = "entry.dev";
|