Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulkar committed Sep 8, 2023
2 parents 7a0f060 + e81d419 commit c8ab36a
Show file tree
Hide file tree
Showing 97 changed files with 5,504 additions and 4,053 deletions.
406 changes: 121 additions & 285 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ lto = "off"
async-recursion = "1.0.2"
# Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.12.2" }
mdxjs = { version = "0.1.15" }
modularize_imports = { version = "0.38.0" }
styled_components = { version = "0.65.0" }
styled_jsx = { version = "0.42.0" }
swc_core = { version = "0.82.10" }
swc_emotion = { version = "0.41.0" }
swc_relay = { version = "0.13.0" }
testing = { version = "0.34.1" }

# Temporarily downgrading these to avoid breaking changes stemming from using
# lightning_css in later versions styled_jsx >= 0.37.0
mdxjs = "=0.1.14"
modularize_imports = { version = "=0.33.0" }
styled_components = { version = "=0.60.0" }
styled_jsx = { version = "=0.37.0" }
swc_core = { version = "=0.79.55", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
swc_emotion = { version = "=0.36.0" }
swc_relay = { version = "=0.8.0" }
testing = { version = "0.33.21" }

auto-hash-map = { path = "crates/turbo-tasks-auto-hash-map" }
node-file-trace = { path = "crates/node-file-trace", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn create_proxy_module(transition_name: &str, target_import: &str) -> Progra
})],
src: Box::new(target_import.into()),
type_only: false,
with: Some(Box::new(ObjectLit {
asserts: Some(Box::new(ObjectLit {
span: DUMMY_SP,
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
key: PropName::Ident(Ident::new(TURBOPACK_HELPER.into(), DUMMY_SP)),
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-ecmascript/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ async fn parse_content(
decorators: true,
decorators_before_export: true,
export_default_from: true,
import_attributes: true,
import_assertions: true,
allow_super_outside_method: true,
allow_return_outside_function: true,
auto_accessors: true,
explicit_resource_management: true,
using_decl: true,
}),
EcmascriptModuleAssetType::Typescript
| EcmascriptModuleAssetType::TypescriptWithTypes => {
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@ pub struct AstPath(#[turbo_tasks(trace_ignore)] Vec<AstParentKind>);
pub static TURBOPACK_HELPER: &str = "__turbopackHelper";

pub fn is_turbopack_helper_import(import: &ImportDecl) -> bool {
import.with.as_ref().map_or(false, |asserts| {
import.asserts.as_ref().map_or(false, |asserts| {
asserts.props.iter().any(|assert| {
assert
.as_prop()
Expand Down
6 changes: 3 additions & 3 deletions crates/turbopack-ecmascript/src/tree_shake/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl DepGraph {
specifiers,
src: Box::new(uri_of_module.clone().into()),
type_only: false,
with: Some(Box::new(create_turbopack_chunk_id_assert(dep))),
asserts: Some(Box::new(create_turbopack_chunk_id_assert(dep))),
})));
}

Expand Down Expand Up @@ -334,7 +334,7 @@ impl DepGraph {
)],
src: None,
type_only: false,
with: Some(Box::new(ObjectLit {
asserts: Some(Box::new(ObjectLit {
span: DUMMY_SP,
props: vec![assertion_prop],
})),
Expand Down Expand Up @@ -787,7 +787,7 @@ impl DepGraph {
})],
src: None,
type_only: false,
with: None,
asserts: None,
})),
export: Some(export.clone()),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/tree_shake/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
// Try to prepend the content of module

let part_id = import
.with
.asserts
.as_deref()
.and_then(find_turbopack_chunk_id_in_asserts);

Expand Down
72 changes: 36 additions & 36 deletions crates/turbopack-ecmascript/tests/tree-shaker/analyzer/1/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,22 +370,22 @@ graph TD
# Modules (dev)
## Part 0
```js
import { foobarCopy } from "entry.js" with {
import { foobarCopy } from "entry.js" assert {
__turbopack_chunk__: 9
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 11
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 10
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 6
};
"module evaluation";
Expand All @@ -396,38 +396,38 @@ console.log(foobarCopy);
```
## Part 1
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 10
};
export { foobar };

```
## Part 2
```js
import { foo } from "entry.js" with {
import { foo } from "entry.js" assert {
__turbopack_chunk__: 6
};
export { foo };

```
## Part 3
```js
import { internal } from "entry.js" with {
import { internal } from "entry.js" assert {
__turbopack_chunk__: 11
};
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 10
};
export { external1 };
Expand All @@ -438,10 +438,10 @@ function external1() {
```
## Part 4
```js
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 6
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 9
};
export { external2 };
Expand All @@ -458,7 +458,7 @@ export { foobar };
```
## Part 6
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
const foo = foobar;
Expand All @@ -473,10 +473,10 @@ export { bar };
```
## Part 8
```js
import { bar } from "entry.js" with {
import { bar } from "entry.js" assert {
__turbopack_chunk__: 7
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 6
};
foobar += bar;
Expand All @@ -485,10 +485,10 @@ export { foobar };
```
## Part 9
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
let foobarCopy = foobar;
Expand All @@ -497,10 +497,10 @@ export { foobarCopy };
```
## Part 10
```js
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 6
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 9
};
foobar += "foo";
Expand All @@ -509,13 +509,13 @@ export { foobar };
```
## Part 11
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 10
};
import { upper } from "module";
Expand Down Expand Up @@ -551,10 +551,10 @@ console.log(foobarCopy);
# Modules (prod)
## Part 0
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 7
};
"module evaluation";
Expand All @@ -566,21 +566,21 @@ export { foobarCopy };
```
## Part 1
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 7
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
export { foobar };

```
## Part 2
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
export { foo };
Expand All @@ -590,13 +590,13 @@ export { foo };
```
## Part 3
```js
import { foobar } from "entry.js" with {
import { foobar } from "entry.js" assert {
__turbopack_chunk__: 5
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 7
};
import "entry.js" with {
import "entry.js" assert {
__turbopack_chunk__: 8
};
export { external1 };
Expand Down Expand Up @@ -631,7 +631,7 @@ export { bar };
```
## Part 7
```js
import { bar } from "entry.js" with {
import { bar } from "entry.js" assert {
__turbopack_chunk__: 6
};
foobar += bar;
Expand Down
Loading

0 comments on commit c8ab36a

Please sign in to comment.