Skip to content

Commit

Permalink
Merge branch 'main' into mehulkar/turbo-955-polish-globalhashsummary-…
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulkar committed Mar 31, 2023
2 parents 6ef58a4 + dcbbf17 commit 6fdf335
Show file tree
Hide file tree
Showing 108 changed files with 367 additions and 928 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ jobs:
next_dev_check:
needs: [determine_jobs]
if: needs.determine_jobs.outputs.rust == 'true'
if: needs.determine_jobs.outputs.turbopack == 'true' || needs.determine_jobs.outputs.cargo_on_main == 'true'
name: Check next-swc
runs-on: ubuntu-latest-8-core-oss
permissions:
Expand All @@ -539,10 +539,17 @@ jobs:
env:
CARGO_TERM_COLOR: never
run: |
export TURBOPACK_REMOTE="https://github.com/vercel/turbo"
# Apply patches to the cargo to the latest turbopack's sha.
export BINDING=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbo-binding" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
export TASKS=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbo-tasks" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
export TASKS_FS=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbo-tasks-fs" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
cd packages/next-swc
cargo check --message-format short --quiet && \
cargo check -p next-swc-napi --features plugin,rustls-tls --message-format short --quiet && \
cargo check -p next-dev --no-default-features --features cli,custom_allocator,rustls-tls,__internal_nextjs_integration_test --message-format short --quiet &> cargo_output.log
cargo check --config $BINDING --config $TASKS --config $TASKS_FS --message-format short --quiet && \
cargo check --config $BINDING --config $TASKS --config $TASKS_FS -p next-swc-napi --features plugin,rustls-tls --message-format short --quiet && \
cargo check --config $BINDING --config $TASKS --config $TASKS_FS -p next-dev --no-default-features --features cli,custom_allocator,rustls-tls,__internal_nextjs_integration_test --message-format short --quiet &> cargo_output.log
- name: Post logs if there are errors
run: |
Expand All @@ -551,6 +558,9 @@ jobs:
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
if: github.repository == 'vercel/turbo'
# We'll not block CI on this step
continue-on-error: true
with:
filePath: ./out.log
comment_tag: check_next_swc_turbopack
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion cli/integration_tests/bad_flag.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Bad flag with an implied run command should display run flags

note: to pass '--bad-flag' as a value, use '-- --bad-flag'

Usage: turbo <--cache-dir <CACHE_DIR>|--cache-workers <CACHE_WORKERS>|--concurrency <CONCURRENCY>|--continue|--dry-run [<DRY_RUN>]|--single-package|--filter <FILTER>|--force|--global-deps <GLOBAL_DEPS>|--graph [<GRAPH>]|--ignore <IGNORE>|--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs <OUTPUT_LOGS>|--only|--parallel|--pkg-inference-root <PKG_INFERENCE_ROOT>|--profile <PROFILE>|--remote-only|--scope <SCOPE>|--since <SINCE>|--summarize <SUMMARIZE>|--log-prefix <LOG_PREFIX>|TASKS|PASS_THROUGH_ARGS|--experimental-space-id <EXPERIMENTAL_SPACE_ID>>
Usage: turbo <--cache-dir <CACHE_DIR>|--cache-workers <CACHE_WORKERS>|--concurrency <CONCURRENCY>|--continue|--dry-run [<DRY_RUN>]|--single-package|--filter <FILTER>|--force|--global-deps <GLOBAL_DEPS>|--graph [<GRAPH>]|--ignore <IGNORE>|--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs <OUTPUT_LOGS>|--only|--parallel|--pkg-inference-root <PKG_INFERENCE_ROOT>|--profile <PROFILE>|--remote-only|--scope <SCOPE>|--since <SINCE>|--summarize [<SUMMARIZE>]|--log-prefix <LOG_PREFIX>|TASKS|PASS_THROUGH_ARGS|--experimental-space-id <EXPERIMENTAL_SPACE_ID>>

For more information, try '--help'.

Expand Down
18 changes: 18 additions & 0 deletions cli/integration_tests/basic_monorepo/run_summary/enable.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ Setup
| true | missing | yes |
| true | true | yes |
| true | false | no |
| true | novalue | yes |

| false | missing | no |
| false | true | yes |
| false | false | no |
| false | novalue | yes |

| missing | missing | no |
| missing | true | yes |
| missing | false | no |
| missing | novalue | yes |


# env var=true, missing flag: yes
Expand All @@ -36,6 +39,11 @@ Setup
$ TURBO_RUN_SUMMARY=true ${TURBO} run build --summarize=false > /dev/null
$ test -d .turbo/runs
[1]
# env var=true, --flag (no value): yes
$ rm -rf .turbo/runs
$ TURBO_RUN_SUMMARY=true ${TURBO} run build --summarize > /dev/null
$ /bin/ls .turbo/runs/*.json | wc -l
\s*1 (re)

# env var=false, missing flag, no
$ rm -rf .turbo/runs
Expand All @@ -52,6 +60,11 @@ Setup
$ TURBO_RUN_SUMMARY=false ${TURBO} run build --summarize=false > /dev/null
$ test -d .turbo/runs
[1]
# env var=false, --flag (no value): yes
$ rm -rf .turbo/runs
$ TURBO_RUN_SUMMARY=false ${TURBO} run build --summarize > /dev/null
$ /bin/ls .turbo/runs/*.json | wc -l
\s*1 (re)

# missing env var, missing flag: no
$ rm -rf .turbo/runs
Expand All @@ -68,3 +81,8 @@ Setup
$ ${TURBO} run build --summarize=false > /dev/null
$ test -d .turbo/runs
[1]
# missing env var, --flag (no value): yes
$ rm -rf .turbo/runs
$ ${TURBO} run build --summarize > /dev/null
$ /bin/ls .turbo/runs/*.json | wc -l
\s*1 (re)
31 changes: 31 additions & 0 deletions cli/integration_tests/signal_handling/ctrlc.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd)

Run script with INT handler and verify that INT gets passed to script

Start turbo in the background
$ ${TURBO} trap &
Save the PID of turbo
$ TURBO_PID=$!
We send INT to turbo, but with a delay to give us time to bring turbo back to
the foreground.
$ sh -c "sleep 1 && kill -2 ${TURBO_PID}" &
Bring turbo back to the foreground
$ fg 1
${TURBO} trap
\xe2\x80\xa2 Packages in scope: test (esc)
\xe2\x80\xa2 Running trap in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
test:trap: cache miss, executing d25759ee0a8e12ae
test:trap:
test:trap: > trap
test:trap: > trap 'echo trap hit; sleep 1; echo trap finish' INT; sleep 5 && echo 'script finish'
test:trap:
test:trap: trap hit
test:trap: trap finish
test:trap: npm ERR! Lifecycle script `trap` failed with error:
test:trap: npm ERR! Error: command failed
test:trap: npm ERR! in workspace: test
test:trap: npm ERR! at location: .*ctrlc.t/apps/test (re)
[1]
8 changes: 8 additions & 0 deletions cli/integration_tests/signal_handling/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Enable jobcontrol as we need it for fg to work
set -m

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
TARGET_DIR=$1
cp -a ${SCRIPT_DIR}/test_repo/. ${TARGET_DIR}/
${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "test",
"scripts": {
"trap": "trap 'echo trap hit; sleep 1; echo trap finish' INT; sleep 5 && echo 'script finish'"
}
}
7 changes: 7 additions & 0 deletions cli/integration_tests/signal_handling/test_repo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "signal-test",
"workspaces": [
"apps/*"
],
"packageManager": "npm@8.0.0"
}
6 changes: 6 additions & 0 deletions cli/integration_tests/signal_handling/test_repo/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"trap": {}
}
}
1 change: 1 addition & 0 deletions crates/turbopack-core/src/reference_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub enum EntryReferenceSubType {
AppPage,
AppRoute,
AppClientComponent,
Runtime,
Custom(u8),
Undefined,
}
Expand Down
10 changes: 0 additions & 10 deletions crates/turbopack-dev/js/src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ const chunkListChunksMap = new Map();
const chunkChunkListsMap = new Map();

const hOP = Object.prototype.hasOwnProperty;
const _process =
typeof process !== "undefined"
? process
: {
env: {},
// Some modules rely on `process.browser` to execute browser-specific code.
// NOTE: `process.browser` is specific to Webpack.
browser: true,
};

const toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag;

Expand Down Expand Up @@ -324,7 +315,6 @@ function instantiateModule(id, source) {
c: moduleCache,
l: loadChunk.bind(null, { type: SourceTypeParent, parentId: id }),
k: registerChunkList,
p: _process,
g: globalThis,
__dirname: module.id.replace(/(^|\/)[\/]+$/, ""),
});
Expand Down
1 change: 0 additions & 1 deletion crates/turbopack-dev/src/ecmascript/module_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub(super) async fn module_factory(content: EcmascriptChunkItemContentVc) -> Res
"l: __turbopack_load__",
"k: __turbopack_register_chunk_list__",
"j: __turbopack_cjs__",
"p: process",
"g: global",
// HACK
"__dirname",
Expand Down
19 changes: 17 additions & 2 deletions crates/turbopack-ecmascript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ use turbo_tasks::{
};
use turbo_tasks_fs::FileSystemPathVc;
use turbopack_core::{
asset::{Asset, AssetContentVc, AssetOptionVc, AssetVc},
asset::{Asset, AssetContentVc, AssetOptionVc, AssetVc, AssetsVc},
chunk::{
availability_info::AvailabilityInfo, ChunkItem, ChunkItemVc, ChunkVc, ChunkableAsset,
ChunkableAssetVc, ChunkingContextVc,
},
compile_time_info::CompileTimeInfoVc,
context::AssetContextVc,
context::{AssetContext, AssetContextVc},
ident::AssetIdentVc,
reference::{AssetReferencesReadRef, AssetReferencesVc},
reference_type::{EntryReferenceSubType, ReferenceType},
resolve::{
origin::{ResolveOrigin, ResolveOriginVc},
parse::RequestVc,
Expand Down Expand Up @@ -563,6 +564,20 @@ async fn gen_content(
}
}

#[turbo_tasks::function]
pub async fn process_runtime_entries(
context: AssetContextVc,
entries: AssetsVc,
) -> Result<EcmascriptChunkPlaceablesVc> {
Ok(EcmascriptChunkPlaceablesVc::cell(entries.await?.iter().copied().map(|asset| async move {
let asset = context.process(asset, Value::new(ReferenceType::Entry(EntryReferenceSubType::Runtime)));
let Some(placeable) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? else {
bail!("{} is not placeable in a ecmascript chunk as runtime entry", asset.ident().to_string().await?)
};
Ok(placeable)
}).try_join().await?))
}

pub fn register() {
turbo_tasks::register();
turbo_tasks_fs::register();
Expand Down
Loading

0 comments on commit 6fdf335

Please sign in to comment.