@qwik.dev/core 2.0.0-alpha.7 → 2.0.0-alpha.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/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +245 -20
- package/dist/core.cjs +7280 -7339
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +7273 -7339
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +1646 -1735
- package/dist/core.prod.mjs +2737 -2849
- package/dist/insights/index.qwik.cjs +1854 -1958
- package/dist/insights/index.qwik.mjs +1854 -1958
- package/dist/insights/insights.d.ts +1 -1
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +65 -18
- package/dist/optimizer.d.ts +1 -1
- package/dist/optimizer.mjs +62 -18
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +42 -41
- package/dist/server.mjs +42 -41
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/tailwind/package.json +2 -2
- package/dist/starters/features/tailwind-v3/.vscode/settings.json +3 -0
- package/dist/starters/features/tailwind-v3/package.json +21 -0
- package/dist/starters/features/tailwind-v3/postcss.config.cjs +6 -0
- package/dist/starters/features/tailwind-v3/src/global.css +7 -0
- package/dist/starters/features/tailwind-v3/tailwind.config.js +8 -0
- package/dist/testing/index.cjs +3723 -3615
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.mjs +3995 -3888
- package/dist/testing/package.json +1 -1
- package/package.json +3 -3
- package/public.d.ts +6 -0
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-alpha.
|
|
3
|
+
* @qwik.dev/core/optimizer 2.0.0-alpha.9-dev+56ed5bd
|
|
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
|
|
@@ -1235,7 +1235,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
};
|
|
1237
1237
|
var versions = {
|
|
1238
|
-
qwik: "2.0.0-alpha.
|
|
1238
|
+
qwik: "2.0.0-alpha.9-dev+56ed5bd"
|
|
1239
1239
|
};
|
|
1240
1240
|
async function getSystem() {
|
|
1241
1241
|
const sysEnv = getEnv();
|
|
@@ -1814,12 +1814,13 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
1814
1814
|
ExperimentalFeatures2.insights = "insights";
|
|
1815
1815
|
return ExperimentalFeatures2;
|
|
1816
1816
|
})(ExperimentalFeatures || {});
|
|
1817
|
-
function
|
|
1817
|
+
function createQwikPlugin(optimizerOptions = {}) {
|
|
1818
1818
|
const id = `${Math.round(899 * Math.random()) + 100}`;
|
|
1819
1819
|
const clientResults = new Map;
|
|
1820
1820
|
const clientTransformedOutputs = new Map;
|
|
1821
1821
|
const serverTransformedOutputs = new Map;
|
|
1822
1822
|
const parentIds = new Map;
|
|
1823
|
+
const npmChunks = new Map;
|
|
1823
1824
|
let internalOptimizer = null;
|
|
1824
1825
|
let linter;
|
|
1825
1826
|
let diagnosticsCallback = () => {};
|
|
@@ -1831,7 +1832,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
1831
1832
|
rootDir: null,
|
|
1832
1833
|
tsconfigFileNames: [ "./tsconfig.json" ],
|
|
1833
1834
|
input: null,
|
|
1834
|
-
outDir:
|
|
1835
|
+
outDir: "",
|
|
1835
1836
|
assetsDir: null,
|
|
1836
1837
|
resolveQwikBuild: true,
|
|
1837
1838
|
entryStrategy: null,
|
|
@@ -2020,6 +2021,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2020
2021
|
debug("transformedOutputs.clear()");
|
|
2021
2022
|
clientTransformedOutputs.clear();
|
|
2022
2023
|
serverTransformedOutputs.clear();
|
|
2024
|
+
npmChunks.clear();
|
|
2023
2025
|
};
|
|
2024
2026
|
const getIsServer = viteOpts => devServer ? !!(null == viteOpts ? void 0 : viteOpts.ssr) : "ssr" === opts.target || "test" === opts.target;
|
|
2025
2027
|
let resolveIdCount = 0;
|
|
@@ -2359,9 +2361,24 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2359
2361
|
}
|
|
2360
2362
|
}
|
|
2361
2363
|
function manualChunks(id2, {getModuleInfo: getModuleInfo}) {
|
|
2364
|
+
var _a;
|
|
2362
2365
|
const module2 = getModuleInfo(id2);
|
|
2363
2366
|
const segment = module2.meta.segment;
|
|
2364
|
-
|
|
2367
|
+
if (segment) {
|
|
2368
|
+
return segment.entry;
|
|
2369
|
+
}
|
|
2370
|
+
const moduleIndex = id2.indexOf("node_modules");
|
|
2371
|
+
if (-1 === moduleIndex) {
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
const modulePath = id2.slice(moduleIndex + 12);
|
|
2375
|
+
const moduleName = id2.startsWith("@") ? modulePath.split("/").slice(0, 2).join("_") : modulePath.slice(0, modulePath.indexOf("/"));
|
|
2376
|
+
let size = (null == (_a = module2.code) ? void 0 : _a.length) || 0;
|
|
2377
|
+
size += npmChunks.get(moduleName) || 0;
|
|
2378
|
+
npmChunks.set(moduleName, size);
|
|
2379
|
+
if (size > 1e4) {
|
|
2380
|
+
return moduleName;
|
|
2381
|
+
}
|
|
2365
2382
|
}
|
|
2366
2383
|
return {
|
|
2367
2384
|
buildStart: buildStart,
|
|
@@ -2435,7 +2452,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2435
2452
|
var LIB_OUT_DIR = "lib";
|
|
2436
2453
|
var Q_MANIFEST_FILENAME = "q-manifest.json";
|
|
2437
2454
|
function qwikRollup(qwikRollupOpts = {}) {
|
|
2438
|
-
const qwikPlugin =
|
|
2455
|
+
const qwikPlugin = createQwikPlugin(qwikRollupOpts.optimizerOptions);
|
|
2439
2456
|
const rollupPlugin = {
|
|
2440
2457
|
name: "rollup-plugin-qwik",
|
|
2441
2458
|
api: {
|
|
@@ -2474,7 +2491,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2474
2491
|
inputOpts.input || (inputOpts.input = opts.input);
|
|
2475
2492
|
return inputOpts;
|
|
2476
2493
|
},
|
|
2477
|
-
outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin
|
|
2494
|
+
outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, false),
|
|
2478
2495
|
async buildStart() {
|
|
2479
2496
|
qwikPlugin.onDiagnostics(((diagnostics, optimizer, srcDir) => {
|
|
2480
2497
|
diagnostics.forEach((d => {
|
|
@@ -2528,29 +2545,45 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2528
2545
|
};
|
|
2529
2546
|
return rollupPlugin;
|
|
2530
2547
|
}
|
|
2531
|
-
function normalizeRollupOutputOptions(
|
|
2548
|
+
function normalizeRollupOutputOptions(qwikPlugin, rollupOutputOpts, useAssetsDir, outDir) {
|
|
2532
2549
|
if (Array.isArray(rollupOutputOpts)) {
|
|
2533
2550
|
rollupOutputOpts.length || rollupOutputOpts.push({});
|
|
2534
2551
|
return rollupOutputOpts.map((outputOptsObj => ({
|
|
2535
|
-
...normalizeRollupOutputOptionsObject(
|
|
2552
|
+
...normalizeRollupOutputOptionsObject(qwikPlugin, outputOptsObj, useAssetsDir),
|
|
2536
2553
|
dir: outDir || outputOptsObj.dir
|
|
2537
2554
|
})));
|
|
2538
2555
|
}
|
|
2539
2556
|
return {
|
|
2540
|
-
...normalizeRollupOutputOptionsObject(
|
|
2557
|
+
...normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, useAssetsDir),
|
|
2541
2558
|
dir: outDir || (null == rollupOutputOpts ? void 0 : rollupOutputOpts.dir)
|
|
2542
2559
|
};
|
|
2543
2560
|
}
|
|
2544
|
-
function normalizeRollupOutputOptionsObject(
|
|
2561
|
+
function normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOptsObj, useAssetsDir) {
|
|
2545
2562
|
const outputOpts = {
|
|
2546
2563
|
...rollupOutputOptsObj
|
|
2547
2564
|
};
|
|
2565
|
+
const opts = qwikPlugin.getOptions();
|
|
2566
|
+
const optimizer = qwikPlugin.getOptimizer();
|
|
2567
|
+
const manualChunks = qwikPlugin.manualChunks;
|
|
2548
2568
|
if ("client" === opts.target) {
|
|
2549
2569
|
if (!outputOpts.assetFileNames) {
|
|
2550
2570
|
const assetFileNames = "assets/[hash]-[name].[ext]";
|
|
2551
2571
|
outputOpts.assetFileNames = useAssetsDir ? `${opts.assetsDir}/${assetFileNames}` : assetFileNames;
|
|
2552
2572
|
}
|
|
2553
|
-
|
|
2573
|
+
let fileName;
|
|
2574
|
+
fileName = "production" !== opts.buildMode || opts.debug ? chunkInfo => {
|
|
2575
|
+
var _a, _b;
|
|
2576
|
+
if (null == (_a = chunkInfo.moduleIds) ? void 0 : _a.some((id => id.endsWith("core.prod.mjs")))) {
|
|
2577
|
+
return "build/core.js";
|
|
2578
|
+
}
|
|
2579
|
+
if (null == (_b = chunkInfo.moduleIds) ? void 0 : _b.some((id => id.endsWith("qwik-router/lib/index.qwik.mjs")))) {
|
|
2580
|
+
return "build/qwik-router.js";
|
|
2581
|
+
}
|
|
2582
|
+
const path = optimizer.sys.path;
|
|
2583
|
+
const relativePath = path.relative(optimizer.sys.cwd(), chunkInfo.name);
|
|
2584
|
+
const sanitized = relativePath.replace(/^(\.\.\/)+/, "").replace(/^\/+/, "").replace(/\//g, "-");
|
|
2585
|
+
return `build/${sanitized}.js`;
|
|
2586
|
+
} : "build/q-[hash].js";
|
|
2554
2587
|
outputOpts.entryFileNames || (outputOpts.entryFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
|
|
2555
2588
|
outputOpts.chunkFileNames || (outputOpts.chunkFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
|
|
2556
2589
|
} else {
|
|
@@ -2570,11 +2603,12 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2570
2603
|
return outputOpts;
|
|
2571
2604
|
}
|
|
2572
2605
|
function createRollupError2(id, diagnostic) {
|
|
2573
|
-
|
|
2606
|
+
var _a;
|
|
2607
|
+
const loc = null == (_a = diagnostic.highlights) ? void 0 : _a[0];
|
|
2574
2608
|
const err = Object.assign(new Error(diagnostic.message), {
|
|
2575
2609
|
id: id,
|
|
2576
2610
|
plugin: "qwik",
|
|
2577
|
-
loc: {
|
|
2611
|
+
loc: loc && {
|
|
2578
2612
|
column: loc.startCol,
|
|
2579
2613
|
line: loc.startLine
|
|
2580
2614
|
},
|
|
@@ -2896,6 +2930,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2896
2930
|
return;
|
|
2897
2931
|
}
|
|
2898
2932
|
const hasQwikRouter = null == (_a = server.config.plugins) ? void 0 : _a.some((plugin => "vite-plugin-qwik-router" === plugin.name));
|
|
2933
|
+
const cssImportedByCSS = new Set;
|
|
2899
2934
|
server.middlewares.use((async (req, res, next) => {
|
|
2900
2935
|
try {
|
|
2901
2936
|
const {ORIGIN: ORIGIN} = process.env;
|
|
@@ -2954,11 +2989,17 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2954
2989
|
const {pathId: pathId, query: query} = parseId(v.url);
|
|
2955
2990
|
if ("" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
|
|
2956
2991
|
const isEntryCSS = 0 === v.importers.size;
|
|
2992
|
+
const hasCSSImporter = Array.from(v.importers).some((importer => {
|
|
2993
|
+
const importerPath = importer.url || importer.file;
|
|
2994
|
+
const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
|
|
2995
|
+
isCSS && v.url && cssImportedByCSS.add(v.url);
|
|
2996
|
+
return isCSS;
|
|
2997
|
+
}));
|
|
2957
2998
|
const hasJSImporter = Array.from(v.importers).some((importer => {
|
|
2958
2999
|
const importerPath = importer.url || importer.file;
|
|
2959
3000
|
return importerPath && JS_EXTENSIONS.test(importerPath);
|
|
2960
3001
|
}));
|
|
2961
|
-
if ((isEntryCSS || hasJSImporter) && !added.has(v.url)) {
|
|
3002
|
+
if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url) && !added.has(v.url)) {
|
|
2962
3003
|
added.add(v.url);
|
|
2963
3004
|
manifest.injections.push({
|
|
2964
3005
|
tag: "link",
|
|
@@ -2997,11 +3038,17 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
2997
3038
|
const {pathId: pathId, query: query} = parseId(v.url);
|
|
2998
3039
|
if (!added.has(v.url) && "" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
|
|
2999
3040
|
const isEntryCSS = 0 === v.importers.size;
|
|
3041
|
+
const hasCSSImporter = Array.from(v.importers).some((importer => {
|
|
3042
|
+
const importerPath = importer.url || importer.file;
|
|
3043
|
+
const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
|
|
3044
|
+
isCSS && v.url && cssImportedByCSS.add(v.url);
|
|
3045
|
+
return isCSS;
|
|
3046
|
+
}));
|
|
3000
3047
|
const hasJSImporter = Array.from(v.importers).some((importer => {
|
|
3001
3048
|
const importerPath = importer.url || importer.file;
|
|
3002
3049
|
return importerPath && JS_EXTENSIONS.test(importerPath);
|
|
3003
3050
|
}));
|
|
3004
|
-
if (isEntryCSS || hasJSImporter) {
|
|
3051
|
+
if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url)) {
|
|
3005
3052
|
res.write(`<link rel="stylesheet" href="${base}${v.url.slice(1)}">`);
|
|
3006
3053
|
added.add(v.url);
|
|
3007
3054
|
}
|
|
@@ -3149,7 +3196,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3149
3196
|
let ssrOutDir = null;
|
|
3150
3197
|
const fileFilter = qwikViteOpts.fileFilter ? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter(id, type) : () => true;
|
|
3151
3198
|
const injections = [];
|
|
3152
|
-
const qwikPlugin =
|
|
3199
|
+
const qwikPlugin = createQwikPlugin(qwikViteOpts.optimizerOptions);
|
|
3153
3200
|
async function loadQwikInsights(clientOutDir2 = "") {
|
|
3154
3201
|
const sys = qwikPlugin.getSys();
|
|
3155
3202
|
const cwdRelativePath = absolutePathAwareJoin(sys.path, rootDir || ".", clientOutDir2, "q-insights.json");
|
|
@@ -3324,7 +3371,7 @@ globalThis.qwikOptimizer = function(module) {
|
|
|
3324
3371
|
const origOnwarn = null == (_t = updatedViteConfig.build.rollupOptions) ? void 0 : _t.onwarn;
|
|
3325
3372
|
updatedViteConfig.build.rollupOptions = {
|
|
3326
3373
|
input: opts.input,
|
|
3327
|
-
output: normalizeRollupOutputOptions(
|
|
3374
|
+
output: normalizeRollupOutputOptions(qwikPlugin, null == (_v = null == (_u = viteConfig.build) ? void 0 : _u.rollupOptions) ? void 0 : _v.output, useAssetsDir, buildOutputDir),
|
|
3328
3375
|
preserveEntrySignatures: "exports-only",
|
|
3329
3376
|
onwarn: (warning, warn) => {
|
|
3330
3377
|
if ("typescript" === warning.plugin && warning.message.includes("outputToFilesystem")) {
|
package/dist/optimizer.d.ts
CHANGED
package/dist/optimizer.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/optimizer 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core/optimizer 2.0.0-alpha.9-dev+56ed5bd
|
|
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
|
|
@@ -1260,7 +1260,7 @@ var QWIK_BINDING_MAP = {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
|
|
1262
1262
|
var versions = {
|
|
1263
|
-
qwik: "2.0.0-alpha.
|
|
1263
|
+
qwik: "2.0.0-alpha.9-dev+56ed5bd"
|
|
1264
1264
|
};
|
|
1265
1265
|
|
|
1266
1266
|
async function getSystem() {
|
|
@@ -1830,12 +1830,13 @@ var ExperimentalFeatures = (ExperimentalFeatures2 => {
|
|
|
1830
1830
|
return ExperimentalFeatures2;
|
|
1831
1831
|
})(ExperimentalFeatures || {});
|
|
1832
1832
|
|
|
1833
|
-
function
|
|
1833
|
+
function createQwikPlugin(optimizerOptions = {}) {
|
|
1834
1834
|
const id = `${Math.round(899 * Math.random()) + 100}`;
|
|
1835
1835
|
const clientResults = new Map;
|
|
1836
1836
|
const clientTransformedOutputs = new Map;
|
|
1837
1837
|
const serverTransformedOutputs = new Map;
|
|
1838
1838
|
const parentIds = new Map;
|
|
1839
|
+
const npmChunks = new Map;
|
|
1839
1840
|
let internalOptimizer = null;
|
|
1840
1841
|
let linter;
|
|
1841
1842
|
let diagnosticsCallback = () => {};
|
|
@@ -1847,7 +1848,7 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
1847
1848
|
rootDir: null,
|
|
1848
1849
|
tsconfigFileNames: [ "./tsconfig.json" ],
|
|
1849
1850
|
input: null,
|
|
1850
|
-
outDir:
|
|
1851
|
+
outDir: "",
|
|
1851
1852
|
assetsDir: null,
|
|
1852
1853
|
resolveQwikBuild: true,
|
|
1853
1854
|
entryStrategy: null,
|
|
@@ -2036,6 +2037,7 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2036
2037
|
debug("transformedOutputs.clear()");
|
|
2037
2038
|
clientTransformedOutputs.clear();
|
|
2038
2039
|
serverTransformedOutputs.clear();
|
|
2040
|
+
npmChunks.clear();
|
|
2039
2041
|
};
|
|
2040
2042
|
const getIsServer = viteOpts => devServer ? !!viteOpts?.ssr : "ssr" === opts.target || "test" === opts.target;
|
|
2041
2043
|
let resolveIdCount = 0;
|
|
@@ -2374,7 +2376,21 @@ function createPlugin(optimizerOptions = {}) {
|
|
|
2374
2376
|
function manualChunks(id2, {getModuleInfo: getModuleInfo}) {
|
|
2375
2377
|
const module = getModuleInfo(id2);
|
|
2376
2378
|
const segment = module.meta.segment;
|
|
2377
|
-
|
|
2379
|
+
if (segment) {
|
|
2380
|
+
return segment.entry;
|
|
2381
|
+
}
|
|
2382
|
+
const moduleIndex = id2.indexOf("node_modules");
|
|
2383
|
+
if (-1 === moduleIndex) {
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
const modulePath = id2.slice(moduleIndex + 12);
|
|
2387
|
+
const moduleName = id2.startsWith("@") ? modulePath.split("/").slice(0, 2).join("_") : modulePath.slice(0, modulePath.indexOf("/"));
|
|
2388
|
+
let size = module.code?.length || 0;
|
|
2389
|
+
size += npmChunks.get(moduleName) || 0;
|
|
2390
|
+
npmChunks.set(moduleName, size);
|
|
2391
|
+
if (size > 1e4) {
|
|
2392
|
+
return moduleName;
|
|
2393
|
+
}
|
|
2378
2394
|
}
|
|
2379
2395
|
return {
|
|
2380
2396
|
buildStart: buildStart,
|
|
@@ -2467,7 +2483,7 @@ var LIB_OUT_DIR = "lib";
|
|
|
2467
2483
|
var Q_MANIFEST_FILENAME = "q-manifest.json";
|
|
2468
2484
|
|
|
2469
2485
|
function qwikRollup(qwikRollupOpts = {}) {
|
|
2470
|
-
const qwikPlugin =
|
|
2486
|
+
const qwikPlugin = createQwikPlugin(qwikRollupOpts.optimizerOptions);
|
|
2471
2487
|
const rollupPlugin = {
|
|
2472
2488
|
name: "rollup-plugin-qwik",
|
|
2473
2489
|
api: {
|
|
@@ -2505,7 +2521,7 @@ function qwikRollup(qwikRollupOpts = {}) {
|
|
|
2505
2521
|
inputOpts.input || (inputOpts.input = opts.input);
|
|
2506
2522
|
return inputOpts;
|
|
2507
2523
|
},
|
|
2508
|
-
outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin
|
|
2524
|
+
outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, false),
|
|
2509
2525
|
async buildStart() {
|
|
2510
2526
|
qwikPlugin.onDiagnostics(((diagnostics, optimizer, srcDir) => {
|
|
2511
2527
|
diagnostics.forEach((d => {
|
|
@@ -2559,30 +2575,45 @@ function qwikRollup(qwikRollupOpts = {}) {
|
|
|
2559
2575
|
return rollupPlugin;
|
|
2560
2576
|
}
|
|
2561
2577
|
|
|
2562
|
-
function normalizeRollupOutputOptions(
|
|
2578
|
+
function normalizeRollupOutputOptions(qwikPlugin, rollupOutputOpts, useAssetsDir, outDir) {
|
|
2563
2579
|
if (Array.isArray(rollupOutputOpts)) {
|
|
2564
2580
|
rollupOutputOpts.length || rollupOutputOpts.push({});
|
|
2565
2581
|
return rollupOutputOpts.map((outputOptsObj => ({
|
|
2566
|
-
...normalizeRollupOutputOptionsObject(
|
|
2582
|
+
...normalizeRollupOutputOptionsObject(qwikPlugin, outputOptsObj, useAssetsDir),
|
|
2567
2583
|
dir: outDir || outputOptsObj.dir
|
|
2568
2584
|
})));
|
|
2569
2585
|
}
|
|
2570
2586
|
return {
|
|
2571
|
-
...normalizeRollupOutputOptionsObject(
|
|
2587
|
+
...normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, useAssetsDir),
|
|
2572
2588
|
dir: outDir || rollupOutputOpts?.dir
|
|
2573
2589
|
};
|
|
2574
2590
|
}
|
|
2575
2591
|
|
|
2576
|
-
function normalizeRollupOutputOptionsObject(
|
|
2592
|
+
function normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOptsObj, useAssetsDir) {
|
|
2577
2593
|
const outputOpts = {
|
|
2578
2594
|
...rollupOutputOptsObj
|
|
2579
2595
|
};
|
|
2596
|
+
const opts = qwikPlugin.getOptions();
|
|
2597
|
+
const optimizer = qwikPlugin.getOptimizer();
|
|
2598
|
+
const manualChunks = qwikPlugin.manualChunks;
|
|
2580
2599
|
if ("client" === opts.target) {
|
|
2581
2600
|
if (!outputOpts.assetFileNames) {
|
|
2582
2601
|
const assetFileNames = "assets/[hash]-[name].[ext]";
|
|
2583
2602
|
outputOpts.assetFileNames = useAssetsDir ? `${opts.assetsDir}/${assetFileNames}` : assetFileNames;
|
|
2584
2603
|
}
|
|
2585
|
-
|
|
2604
|
+
let fileName;
|
|
2605
|
+
fileName = "production" !== opts.buildMode || opts.debug ? chunkInfo => {
|
|
2606
|
+
if (chunkInfo.moduleIds?.some((id => id.endsWith("core.prod.mjs")))) {
|
|
2607
|
+
return "build/core.js";
|
|
2608
|
+
}
|
|
2609
|
+
if (chunkInfo.moduleIds?.some((id => id.endsWith("qwik-router/lib/index.qwik.mjs")))) {
|
|
2610
|
+
return "build/qwik-router.js";
|
|
2611
|
+
}
|
|
2612
|
+
const path = optimizer.sys.path;
|
|
2613
|
+
const relativePath = path.relative(optimizer.sys.cwd(), chunkInfo.name);
|
|
2614
|
+
const sanitized = relativePath.replace(/^(\.\.\/)+/, "").replace(/^\/+/, "").replace(/\//g, "-");
|
|
2615
|
+
return `build/${sanitized}.js`;
|
|
2616
|
+
} : "build/q-[hash].js";
|
|
2586
2617
|
outputOpts.entryFileNames || (outputOpts.entryFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
|
|
2587
2618
|
outputOpts.chunkFileNames || (outputOpts.chunkFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
|
|
2588
2619
|
} else {
|
|
@@ -2603,11 +2634,11 @@ function normalizeRollupOutputOptionsObject(opts, rollupOutputOptsObj, useAssets
|
|
|
2603
2634
|
}
|
|
2604
2635
|
|
|
2605
2636
|
function createRollupError2(id, diagnostic) {
|
|
2606
|
-
const loc = diagnostic.highlights[0]
|
|
2637
|
+
const loc = diagnostic.highlights?.[0];
|
|
2607
2638
|
const err = Object.assign(new Error(diagnostic.message), {
|
|
2608
2639
|
id: id,
|
|
2609
2640
|
plugin: "qwik",
|
|
2610
|
-
loc: {
|
|
2641
|
+
loc: loc && {
|
|
2611
2642
|
column: loc.startCol,
|
|
2612
2643
|
line: loc.startLine
|
|
2613
2644
|
},
|
|
@@ -3049,6 +3080,7 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3049
3080
|
return;
|
|
3050
3081
|
}
|
|
3051
3082
|
const hasQwikRouter = server.config.plugins?.some((plugin => "vite-plugin-qwik-router" === plugin.name));
|
|
3083
|
+
const cssImportedByCSS = new Set;
|
|
3052
3084
|
server.middlewares.use((async (req, res, next) => {
|
|
3053
3085
|
try {
|
|
3054
3086
|
const {ORIGIN: ORIGIN} = process.env;
|
|
@@ -3106,11 +3138,17 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3106
3138
|
const {pathId: pathId, query: query} = parseId(v.url);
|
|
3107
3139
|
if ("" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
|
|
3108
3140
|
const isEntryCSS = 0 === v.importers.size;
|
|
3141
|
+
const hasCSSImporter = Array.from(v.importers).some((importer => {
|
|
3142
|
+
const importerPath = importer.url || importer.file;
|
|
3143
|
+
const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
|
|
3144
|
+
isCSS && v.url && cssImportedByCSS.add(v.url);
|
|
3145
|
+
return isCSS;
|
|
3146
|
+
}));
|
|
3109
3147
|
const hasJSImporter = Array.from(v.importers).some((importer => {
|
|
3110
3148
|
const importerPath = importer.url || importer.file;
|
|
3111
3149
|
return importerPath && JS_EXTENSIONS.test(importerPath);
|
|
3112
3150
|
}));
|
|
3113
|
-
if ((isEntryCSS || hasJSImporter) && !added.has(v.url)) {
|
|
3151
|
+
if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url) && !added.has(v.url)) {
|
|
3114
3152
|
added.add(v.url);
|
|
3115
3153
|
manifest.injections.push({
|
|
3116
3154
|
tag: "link",
|
|
@@ -3149,11 +3187,17 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
|
|
|
3149
3187
|
const {pathId: pathId, query: query} = parseId(v.url);
|
|
3150
3188
|
if (!added.has(v.url) && "" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
|
|
3151
3189
|
const isEntryCSS = 0 === v.importers.size;
|
|
3190
|
+
const hasCSSImporter = Array.from(v.importers).some((importer => {
|
|
3191
|
+
const importerPath = importer.url || importer.file;
|
|
3192
|
+
const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
|
|
3193
|
+
isCSS && v.url && cssImportedByCSS.add(v.url);
|
|
3194
|
+
return isCSS;
|
|
3195
|
+
}));
|
|
3152
3196
|
const hasJSImporter = Array.from(v.importers).some((importer => {
|
|
3153
3197
|
const importerPath = importer.url || importer.file;
|
|
3154
3198
|
return importerPath && JS_EXTENSIONS.test(importerPath);
|
|
3155
3199
|
}));
|
|
3156
|
-
if (isEntryCSS || hasJSImporter) {
|
|
3200
|
+
if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url)) {
|
|
3157
3201
|
res.write(`<link rel="stylesheet" href="${base}${v.url.slice(1)}">`);
|
|
3158
3202
|
added.add(v.url);
|
|
3159
3203
|
}
|
|
@@ -3319,7 +3363,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3319
3363
|
let ssrOutDir = null;
|
|
3320
3364
|
const fileFilter = qwikViteOpts.fileFilter ? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter(id, type) : () => true;
|
|
3321
3365
|
const injections = [];
|
|
3322
|
-
const qwikPlugin =
|
|
3366
|
+
const qwikPlugin = createQwikPlugin(qwikViteOpts.optimizerOptions);
|
|
3323
3367
|
async function loadQwikInsights(clientOutDir2 = "") {
|
|
3324
3368
|
const sys = qwikPlugin.getSys();
|
|
3325
3369
|
const cwdRelativePath = absolutePathAwareJoin(sys.path, rootDir || ".", clientOutDir2, "q-insights.json");
|
|
@@ -3493,7 +3537,7 @@ function qwikVite(qwikViteOpts = {}) {
|
|
|
3493
3537
|
const origOnwarn = updatedViteConfig.build.rollupOptions?.onwarn;
|
|
3494
3538
|
updatedViteConfig.build.rollupOptions = {
|
|
3495
3539
|
input: opts.input,
|
|
3496
|
-
output: normalizeRollupOutputOptions(
|
|
3540
|
+
output: normalizeRollupOutputOptions(qwikPlugin, viteConfig.build?.rollupOptions?.output, useAssetsDir, buildOutputDir),
|
|
3497
3541
|
preserveEntrySignatures: "exports-only",
|
|
3498
3542
|
onwarn: (warning, warn) => {
|
|
3499
3543
|
if ("typescript" === warning.plugin && warning.message.includes("outputToFilesystem")) {
|