Skip to content

Commit

Permalink
Merge branch 'main' into olszewski/fix_berry_parse
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-olszewski committed May 15, 2023
2 parents 1572301 + a27ea3e commit f487d47
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 187 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/turbo/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const turboVersion = "1.9.5-canary.1"
const turboVersion = "1.9.5"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::is_server_module;
pub struct ServerDirectiveTransformer {
// ServerDirective is not implemented yet and always reports an issue.
// We don't have to pass a valid transition name yet, but the API is prepared.
#[allow(unused)]
transition_name: StringVc,
}

Expand Down
39 changes: 1 addition & 38 deletions crates/turbopack-ecmascript/src/transform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
mod server_to_client_proxy;
mod util;

use std::{fmt::Debug, hash::Hash, path::PathBuf, sync::Arc};

use anyhow::Result;
Expand All @@ -13,12 +10,11 @@ use swc_core::{
atoms::JsWord,
preset_env::{self, Targets},
transforms::{
base::{feature::FeatureFlag, helpers::inject_helpers, resolver, Assumptions},
base::{feature::FeatureFlag, helpers::inject_helpers, Assumptions},
react::react,
},
visit::{FoldWith, VisitMutWith},
},
quote,
};
use turbo_tasks::primitives::{OptionStringVc, StringVc, StringsVc};
use turbo_tasks_fs::FileSystemPathVc;
Expand All @@ -27,16 +23,9 @@ use turbopack_core::{
issue::{Issue, IssueSeverity, IssueSeverityVc, IssueVc},
};

use self::{
server_to_client_proxy::create_proxy_module,
util::{is_client_module, is_server_module},
};

#[turbo_tasks::value(serialization = "auto_for_input")]
#[derive(Debug, Clone, PartialOrd, Ord, Hash)]
pub enum EcmascriptInputTransform {
ClientDirective(StringVc),
ServerDirective(StringVc),
CommonJs,
Plugin(TransformPluginVc),
PresetEnv(EnvironmentVc),
Expand Down Expand Up @@ -148,7 +137,6 @@ impl EcmascriptInputTransform {
source_map,
top_level_mark,
unresolved_mark,
file_name_str,
file_name_hash,
file_path,
..
Expand Down Expand Up @@ -326,31 +314,6 @@ impl EcmascriptInputTransform {
inject_helpers(unresolved_mark)
));
}
// [TODO]: WEB-940 - use ClientDirectiveTransformer in next-swc
EcmascriptInputTransform::ClientDirective(transition_name) => {
if is_client_module(program) {
let transition_name = &*transition_name.await?;
*program = create_proxy_module(transition_name, &format!("./{file_name_str}"));
program.visit_mut_with(&mut resolver(unresolved_mark, top_level_mark, false));
}
}
// [TODO]: WEB-940 - use ServerDirectiveTransformer in next-swc
EcmascriptInputTransform::ServerDirective(_transition_name) => {
if is_server_module(program) {
let stmt = quote!(
"throw new Error('Server actions (\"use server\") are not yet supported in \
Turbopack');" as Stmt
);
match program {
Program::Module(m) => m.body = vec![ModuleItem::Stmt(stmt)],
Program::Script(s) => s.body = vec![stmt],
}
UnsupportedServerActionIssue { context: file_path }
.cell()
.as_issue()
.emit();
}
}
EcmascriptInputTransform::Plugin(transform) => {
transform.await?.transform(program, ctx).await?
}
Expand Down

This file was deleted.

35 changes: 0 additions & 35 deletions crates/turbopack-ecmascript/src/transform/util.rs

This file was deleted.

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

2 changes: 1 addition & 1 deletion crates/turbopack/src/module_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl ModuleOptionsVc {
let jsx = enable_jsx.await?;

transforms.push(EcmascriptInputTransform::React {
refresh: enable_react_refresh,
refresh: enable_react_refresh || jsx.react_refresh,
import_source: OptionStringVc::cell(jsx.import_source.clone()),
runtime: OptionStringVc::cell(jsx.runtime.clone()),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ impl WebpackLoadersOptions {
}
}

// [TODO]: should enabled_react_refresh belong to this options?
#[turbo_tasks::value(shared)]
#[derive(Default, Clone, Debug)]
pub struct JsxTransformOptions {
pub react_refresh: bool,
pub import_source: Option<String>,
pub runtime: Option<String>,
}
Expand Down
26 changes: 14 additions & 12 deletions packages/create-turbo/__tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ describe("git", () => {
const { root } = useFixture({ fixture: `git` });
const mockExecSync = jest
.spyOn(childProcess, "execSync")
.mockReturnValueOnce("git version 2.38.1")
.mockImplementationOnce(() => {
throw new Error(
"fatal: not a git repository (or any of the parent directories): .git"
Expand All @@ -139,11 +138,9 @@ describe("git", () => {
expect(result).toBe(true);

const calls = [
"git --version",
"git init",
"git checkout -b main",
"git add -A",
'git commit -m "test commit"',
'git commit --author="Turbobot <turbobot@vercel.com>" -am "test commit"',
];
expect(mockExecSync).toHaveBeenCalledTimes(calls.length + 2);
calls.forEach((call) => {
Expand All @@ -160,16 +157,15 @@ describe("git", () => {
});
const mockExecSync = jest
.spyOn(childProcess, "execSync")
.mockReturnValueOnce("git version 2.38.1")
.mockReturnValueOnce("true")
.mockReturnValue("success");

const result = tryGitInit(root, "test commit");
expect(result).toBe(false);

const calls = ["git --version"];
const calls: string[] = [];

// 1 call for git --version, 1 call for isInGitRepository
// 1 call for isInGitRepository
expect(mockExecSync).toHaveBeenCalledTimes(calls.length + 1);
calls.forEach((call) => {
expect(mockExecSync).toHaveBeenCalledWith(call, {
Expand All @@ -184,13 +180,21 @@ describe("git", () => {
const mockExecSync = jest
.spyOn(childProcess, "execSync")
.mockImplementationOnce(() => {
throw new Error("fatal: unknown command git");
throw new Error(
"fatal: not a git repository (or any of the parent directories): .git"
);
})
.mockImplementationOnce(() => {
throw new Error("abort: no repository found (.hg not found)");
})
.mockImplementationOnce(() => {
throw new Error("fatal: 128");
});

const result = tryGitInit(root, "test commit");
expect(result).toBe(false);

const calls = ["git --version"];
const calls: string[] = [GIT_REPO_COMMAND, HG_REPO_COMMAND, "git init"];

expect(mockExecSync).toHaveBeenCalledTimes(calls.length);
calls.forEach((call) => {
Expand All @@ -205,7 +209,6 @@ describe("git", () => {
const { root } = useFixture({ fixture: `git` });
const mockExecSync = jest
.spyOn(childProcess, "execSync")
.mockReturnValueOnce("git version 2.38.1")
.mockImplementationOnce(() => {
throw new Error(
"fatal: not a git repository (or any of the parent directories): .git"
Expand All @@ -224,10 +227,9 @@ describe("git", () => {
expect(result).toBe(false);

const calls = [
"git --version",
"git init",
"git checkout -b main",
"git add -A",
'git commit --author="Turbobot <turbobot@vercel.com>" -am "test commit"',
];

expect(mockExecSync).toHaveBeenCalledTimes(calls.length + 2);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-turbo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-turbo",
"version": "1.9.5-canary.1",
"version": "1.9.5",
"description": "Create a new Turborepo",
"homepage": "https://turbo.build/repo",
"license": "MPL-2.0",
Expand Down
Loading

0 comments on commit f487d47

Please sign in to comment.