Skip to content

Commit

Permalink
fix: server can now properly import @builder.io/qwik
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jun 21, 2021
1 parent 1b731cc commit d43c376
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .bazelignore
@@ -0,0 +1,6 @@
node_modules
dist
bazel-bin
basel-out
bazel-qwik
bazel-testlogs
5 changes: 4 additions & 1 deletion integration/BUILD.bazel
Expand Up @@ -47,7 +47,9 @@ nodejs_binary(
":static_files",
"//src:qwikloader",
"//src:qwikloader.min",
"//src/core",
# The next two lines are duplicates and should be unifed somehow.
"//src/core", # This is needed so that `import '@builder.io/qwik'` works
"//src:core.js", # This is needed so that server can serve '@builder.io/qwik` as single file.
"//src/server",
"@npm//domino",
],
Expand All @@ -56,6 +58,7 @@ nodejs_binary(
"--node_options=--experimental-modules",
"--nobazel_patch_module_resolver",
"--root",
"qwik/src",
"qwik/src/core",
"qwik/integration",
],
Expand Down
2 changes: 1 addition & 1 deletion integration/hello_server/qwik.ts
Expand Up @@ -12,4 +12,4 @@
* This file is to simulate the import from `./qwik.js` which the server serves
* as `//src/core/qwik.ts`
*/
export * from 'qwik';
export * from '@builder.io/qwik';
2 changes: 1 addition & 1 deletion integration/hello_static/qwik.ts
Expand Up @@ -12,4 +12,4 @@
* This file is to simulate the import from `./qwik.js` which the server serves
* as `//src/core/qwik.ts`
*/
export * from 'qwik';
export * from '@builder.io/qwik';
2 changes: 1 addition & 1 deletion integration/todo/qwik.ts
Expand Up @@ -12,4 +12,4 @@
* This file is to simulate the import from `./qwik.js` which the server serves
* as `//src/core/qwik.ts`
*/
export * from 'qwik';
export * from '@builder.io/qwik';
2 changes: 1 addition & 1 deletion src/core/BUILD.bazel
Expand Up @@ -6,7 +6,7 @@ package(default_visibility = ["//visibility:public"])

js_library(
name = "core",
package_name = "core",
package_name = "@builder.io/qwik",
srcs = ["package.json"],
deps = [
":project",
Expand Down
1 change: 1 addition & 0 deletions src/core/package.json
@@ -1,3 +1,4 @@
{
"name": "@builder.io/qwik",
"type": "module"
}
6 changes: 4 additions & 2 deletions src/server/main.ts
Expand Up @@ -13,12 +13,14 @@ import * as fs from 'fs';
import { dirname, join } from 'path';
import srcMap from 'source-map-support';
import { fileURLToPath } from 'url';
import { serializeState } from 'qwik';
import { serializeState } from '@builder.io/qwik';

import { findFiles } from './fs_util.js';

srcMap.install();

console.log(process.argv);

async function main(__dirname: string, process: NodeJS.Process) {
console.log('===================================================');
console.log('Starting:', __dirname);
Expand Down Expand Up @@ -93,7 +95,7 @@ async function main(__dirname: string, process: NodeJS.Process) {
function readBundleContent(paths: string[]): string | null {
for (let i = 0; i < paths.length; i++) {
const path = paths[i];
const qwikPath = join(path, 'qwik.js');
const qwikPath = join(path, 'core.js');
const content = fs.readFileSync(qwikPath);
if (content.length) {
console.log('Found Qwik bundle:', qwikPath);
Expand Down
12 changes: 11 additions & 1 deletion tsconfig.json
Expand Up @@ -45,7 +45,7 @@
"baseUrl": "." /* Base directory to resolve non-absolute module names. */,
"paths": {
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"qwik": [
"@builder.io/qwik": [
"src/core/index",
"bazel-out/host/bin/src/core/index",
"bazel-out/darwin-fastbuild/bin/src/core/index",
Expand All @@ -54,6 +54,16 @@
"bazel-out/darwin-dbg/bin/src/core/index",
"bazel-out/k8-dbg/bin/src/core/index",
"bazel-out/x64_windows-dbg/bin/src/core/index"
],
"@builder.io/qwik/*": [
"src/core/*",
"bazel-out/host/bin/src/core/*",
"bazel-out/darwin-fastbuild/bin/src/core/*",
"bazel-out/k8-fastbuild/bin/src/core/*",
"bazel-out/x64_windows-fastbuild/bin/src/core/*",
"bazel-out/darwin-dbg/bin/src/core/*",
"bazel-out/k8-dbg/bin/src/core/*",
"bazel-out/x64_windows-dbg/bin/src/core/*"
]
},
"rootDirs": [
Expand Down

0 comments on commit d43c376

Please sign in to comment.