Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cgoinglove authored Jun 20, 2024
2 parents 36d7658 + 3208478 commit b3aa6ba
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions crates/turbopack-cli/js/src/entry/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { connect } from "@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client";
import { connect } from "@vercel/turbopack-ecmascript-runtime/browser/dev/hmr-client/hmr-client";
import {
connectHMR,
addMessageListener,
sendMessage,
} from "@vercel/turbopack-ecmascript-runtime/dev/client/websocket";
} from "@vercel/turbopack-ecmascript-runtime/browser/dev/hmr-client/websocket";

export function initializeHMR(options: { assetPrefix: string }) {
connect({
Expand Down
10 changes: 5 additions & 5 deletions crates/turbopack-ecmascript-runtime/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"private": true,
"scripts": {
"check": "run-p check:*",
"check:build": "tsc -p src/build",
"check:dev-client": "tsc -p src/dev/client",
"check:dev-runtime-base": "tsc -p src/dev/runtime/base",
"check:dev-runtime-dom": "tsc -p src/dev/runtime/dom",
"check:dev-runtime-edge": "tsc -p src/dev/runtime/edge"
"check:nodejs": "tsc -p src/nodejs",
"check:browser-dev-client": "tsc -p src/browser/dev/hmr-client",
"check:browser-dev-runtime-base": "tsc -p src/browser/dev/runtime/base",
"check:browser-dev-runtime-dom": "tsc -p src/browser/dev/runtime/dom",
"check:browser-dev-runtime-edge": "tsc -p src/browser/dev/runtime/edge"
},
"exports": {
".": "./src/main.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="../../shared/runtime-types.d.ts" />
/// <reference path="../../../shared/runtime-types.d.ts" />
/// <reference path="../runtime/base/globals.d.ts" />
/// <reference path="../runtime/base/protocol.d.ts" />
/// <reference path="../runtime/base/extensions.d.ts" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"skipLibCheck": true,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This interface will be implemented by runtime backends.
*/

/// <reference path="../../../shared/require-type.d.ts" />
/// <reference path="../../../../shared/require-type.d.ts" />

declare var BACKEND: RuntimeBackend;
declare var _eval: (code: EcmascriptModuleEntry) => any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* eslint-disable @next/next/no-assign-module-variable */

/// <reference path="../../../shared/runtime-utils.ts" />
/// <reference path="../../../../shared/runtime-utils.ts" />
/// <reference path="./globals.d.ts" />
/// <reference path="./protocol.d.ts" />
/// <reference path="./extensions.d.ts" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
// environment, we need WebWorker for WebAssembly types
"lib": ["ESNext", "WebWorker"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

/// <reference path="../base/runtime-base.ts" />
/// <reference path="../../../shared/require-type.d.ts" />
/// <reference path="../../../../shared/require-type.d.ts" />

type ChunkResolver = {
resolved: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
// environment
"lib": ["ESNext", "DOM"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

/// <reference path="../base/runtime-base.ts" />
/// <reference path="../../../shared-node/base-externals-utils.ts" />
/// <reference path="../../../shared/require-type.d.ts" />
/// <reference path="../../../../shared-node/base-externals-utils.ts" />
/// <reference path="../../../../shared/require-type.d.ts" />

type ChunkRunner = {
requiredChunks: Set<ChunkPath>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
// environment, we need WebWorker for WebAssembly types
"lib": ["ESNext", "WebWorker"]
Expand Down
10 changes: 6 additions & 4 deletions crates/turbopack-ecmascript-runtime/src/browser_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ pub async fn get_browser_runtime_code(

let shared_runtime_utils_code =
embed_static_code(asset_context, "shared/runtime-utils.ts".into());
let runtime_base_code =
embed_static_code(asset_context, "dev/runtime/base/runtime-base.ts".into());
let runtime_base_code = embed_static_code(
asset_context,
"browser/dev/runtime/base/runtime-base.ts".into(),
);

let chunk_loading = &*asset_context
.compile_time_info()
Expand All @@ -35,12 +37,12 @@ pub async fn get_browser_runtime_code(
let runtime_backend_code = embed_static_code(
asset_context,
match chunk_loading {
ChunkLoading::Edge => "dev/runtime/edge/runtime-backend-edge.ts".into(),
ChunkLoading::Edge => "browser/dev/runtime/edge/runtime-backend-edge.ts".into(),
// This case should never be hit.
ChunkLoading::NodeJs => {
panic!("Node.js runtime is not supported in the browser runtime!")
}
ChunkLoading::Dom => "dev/runtime/dom/runtime-backend-dom.ts".into(),
ChunkLoading::Dom => "browser/dev/runtime/dom/runtime-backend-dom.ts".into(),
},
);

Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-ecmascript-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

pub(crate) mod asset_context;
pub(crate) mod browser_runtime;
pub(crate) mod build_runtime;
#[cfg(feature = "test")]
pub(crate) mod dummy_runtime;
pub(crate) mod embed_js;
pub(crate) mod nodejs_runtime;
pub(crate) mod runtime_type;

pub use browser_runtime::get_browser_runtime_code;
pub use build_runtime::get_nodejs_runtime_code;
#[cfg(feature = "test")]
pub use dummy_runtime::get_dummy_runtime_code;
pub use embed_js::{embed_file, embed_file_path, embed_fs};
pub use nodejs_runtime::get_nodejs_runtime_code;
pub use runtime_type::RuntimeType;

pub fn register() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn get_nodejs_runtime_code(environment: Vc<Environment>) -> Result<Vc<
embed_static_code(asset_context, "shared-node/node-externals-utils.ts".into());
let shared_node_wasm_utils_code =
embed_static_code(asset_context, "shared-node/node-wasm-utils.ts".into());
let runtime_code = embed_static_code(asset_context, "build/runtime.ts".into());
let runtime_code = embed_static_code(asset_context, "nodejs/runtime.ts".into());

let mut code = CodeBuilder::default();
code.push_code(&*shared_runtime_utils_code.await?);
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

0 comments on commit b3aa6ba

Please sign in to comment.