Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vite #171

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "0.0.16-9",
"version": "0.0.16-10",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"scripts": {
"build": "node scripts --tsc --build --api --platform-binding --wasm",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-qwik",
"version": "0.0.13",
"version": "0.0.14",
"description": "Interactive CLI and API for generating Qwik projects.",
"bin": {
"create-qwik": "create-qwik"
Expand Down
39 changes: 22 additions & 17 deletions src/optimizer/src/rollup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export function qwikRollup(opts: QwikPluginOptions): any {
}
return {
esbuild: { include: /\.js$/ },
optimizeDeps: {
include: ['@builder.io/qwik', '@builder.io/qwik/jsx-runtime'],
},
build: {
polyfillModulePreload: false,
dynamicImportVarsOptions: {
Expand Down Expand Up @@ -128,8 +131,7 @@ export function qwikRollup(opts: QwikPluginOptions): any {

const result = await optimizer.transformFs(transformOpts);
for (const output of result.modules) {
let key = optimizer.path.join(transformOpts.rootDir, output.path)!;
key = key.split('.').slice(0, -1).join('.');
const key = optimizer.path.join(transformOpts.rootDir, output.path)!;
if (debug) {
// eslint-disable-next-line no-console
console.debug(`[QWIK PLUGIN] Module: ${key}`);
Expand Down Expand Up @@ -166,24 +168,23 @@ export function qwikRollup(opts: QwikPluginOptions): any {
id = optimizer.path.resolve(dir, id);
}
}
if (transformedOutputs.has(id)) {
if (debug) {
// eslint-disable-next-line no-console
console.debug(`[QWIK PLUGIN] Resolve: ${id} ${opts}`);
}
return {
id,
moduleSideEffects: false,
};
const tries = [id, id + '.js'];
if (['.jsx', '.ts', '.tsx'].includes(optimizer.path.extname(id))) {
tries.push(removeExtension(id) + '.js');
}
if (['.js', '.jsx', '.ts', '.tsx'].includes(optimizer.path.extname(id))) {
id = id.split('.').slice(0, -1).join('.');
if (transformedOutputs.has(id)) {
for (const id of tries) {
const res = transformedOutputs.get(id);
if (res) {
if (debug) {
// eslint-disable-next-line no-console
console.debug(`[QWIK PLUGIN] Resolved: ${id}`);
console.debug(`[QWIK PLUGIN] Resolve: ${id} ${opts}`);
}
return id;
const mod = res[0];
const sideEffects = !mod.isEntry || !mod.hook;
return {
id,
moduleSideEffects: sideEffects,
};
}
}
return null;
Expand Down Expand Up @@ -310,7 +311,7 @@ export function qwikRollup(opts: QwikPluginOptions): any {

hooks.forEach((h) => {
const symbolName = h.name;
let filename = h.canonicalFilename;
let filename = h.canonicalFilename + '.js';
// eslint-disable-next-line
const found = output.find(([_, v]) => {
return (
Expand Down Expand Up @@ -344,6 +345,10 @@ export function qwikRollup(opts: QwikPluginOptions): any {
return plugin;
}

function removeExtension(id: string) {
return id.split('.').slice(0, -1).join('.');
}

/**
* @alpha
*/
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "vite"
},
"devDependencies": {
"@builder.io/qwik": "0.0.16-9",
"@builder.io/qwik": "0.0.16-10",
"typescript": "^4.5.2",
"vite": "2.7.13"
},
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "vite"
},
"devDependencies": {
"@builder.io/qwik": "0.0.16-9",
"@builder.io/qwik": "0.0.16-10",
"typescript": "^4.5.2",
"vite": "2.7.13"
},
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-partytown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "vite"
},
"devDependencies": {
"@builder.io/qwik": "0.0.16-9",
"@builder.io/qwik": "0.0.16-10",
"typescript": "4.5.2",
"vite": "2.7.13"
},
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "vite"
},
"devDependencies": {
"@builder.io/qwik": "0.0.16-9",
"@builder.io/qwik": "0.0.16-10",
"typescript": "^4.5.2",
"vite": "2.7.13"
},
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "vite"
},
"devDependencies": {
"@builder.io/qwik": "0.0.16-9",
"@builder.io/qwik": "0.0.16-10",
"typescript": "^4.5.2",
"vite": "2.7.13"
},
Expand Down
2 changes: 1 addition & 1 deletion starters/dev-server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function removeDir(dir) {
async function ssrApp(req, appName, appDir) {
const buildDir = join(appDir, 'build');
const serverDir = join(buildDir, 'server');
const serverPath = join(serverDir, 'entry.js');
const serverPath = join(serverDir, 'entry.server.js');
const symbolsPath = join(serverDir, 'q-symbols.json');
const symbols = JSON.parse(readFileSync(symbolsPath, 'utf-8'));

Expand Down
2 changes: 1 addition & 1 deletion starters/servers/cloudflare/server/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "cloudflare-worker",
"main": "build/entry.js"
"main": "build/entry.cloudflare.js"
}
2 changes: 1 addition & 1 deletion starters/servers/express/server/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require('express');
const { join } = require('path');
const { existsSync } = require('fs');
const { render } = require('./build/entry.js');
const { render } = require('./build/entry.server.js');
const symbols = require('./q-symbols.json');
const PORT = process.env.PORT || 8080;

Expand Down