From d43c37651b4046d9676a43ce663a617bf0fcbb26 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sun, 20 Jun 2021 13:36:15 -0700 Subject: [PATCH] fix: server can now properly import `@builder.io/qwik` --- .bazelignore | 6 ++++++ integration/BUILD.bazel | 5 ++++- integration/hello_server/qwik.ts | 2 +- integration/hello_static/qwik.ts | 2 +- integration/todo/qwik.ts | 2 +- src/core/BUILD.bazel | 2 +- src/core/package.json | 1 + src/server/main.ts | 6 ++++-- tsconfig.json | 12 +++++++++++- 9 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 .bazelignore diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 00000000000..0bc51ae18f4 --- /dev/null +++ b/.bazelignore @@ -0,0 +1,6 @@ +node_modules +dist +bazel-bin +basel-out +bazel-qwik +bazel-testlogs \ No newline at end of file diff --git a/integration/BUILD.bazel b/integration/BUILD.bazel index 3c007933ece..477fc2f93da 100644 --- a/integration/BUILD.bazel +++ b/integration/BUILD.bazel @@ -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", ], @@ -56,6 +58,7 @@ nodejs_binary( "--node_options=--experimental-modules", "--nobazel_patch_module_resolver", "--root", + "qwik/src", "qwik/src/core", "qwik/integration", ], diff --git a/integration/hello_server/qwik.ts b/integration/hello_server/qwik.ts index e94dee74dc4..a239b1dfea5 100644 --- a/integration/hello_server/qwik.ts +++ b/integration/hello_server/qwik.ts @@ -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'; diff --git a/integration/hello_static/qwik.ts b/integration/hello_static/qwik.ts index e94dee74dc4..a239b1dfea5 100644 --- a/integration/hello_static/qwik.ts +++ b/integration/hello_static/qwik.ts @@ -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'; diff --git a/integration/todo/qwik.ts b/integration/todo/qwik.ts index e94dee74dc4..a239b1dfea5 100644 --- a/integration/todo/qwik.ts +++ b/integration/todo/qwik.ts @@ -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'; diff --git a/src/core/BUILD.bazel b/src/core/BUILD.bazel index 21ef64cf74a..80cd0c8fe99 100644 --- a/src/core/BUILD.bazel +++ b/src/core/BUILD.bazel @@ -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", diff --git a/src/core/package.json b/src/core/package.json index 3dbc1ca591c..b20a8f91228 100644 --- a/src/core/package.json +++ b/src/core/package.json @@ -1,3 +1,4 @@ { + "name": "@builder.io/qwik", "type": "module" } diff --git a/src/server/main.ts b/src/server/main.ts index 3c4a69358cb..65672fcadf0 100644 --- a/src/server/main.ts +++ b/src/server/main.ts @@ -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); @@ -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); diff --git a/tsconfig.json b/tsconfig.json index 3aefb8cf384..53c9db30b76 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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", @@ -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": [