Skip to content

Commit

Permalink
Remove unused app-turbopack files (#62087)
Browse files Browse the repository at this point in the history
## What?

Noticed this file was being `require`ed but doesn't actually hold
anything relevant as the flag it adds was removed already.

Also found that in the next-core crate there were files that are no
longer needed as it uses Next.js directly now. That fixes a bug when
running with `NextMode::Build` as well, as it couldn't resolve some of
these unused files.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2500
  • Loading branch information
timneutkens committed Feb 15, 2024
1 parent b3cd381 commit 079fe54
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 100 deletions.

This file was deleted.

This file was deleted.

82 changes: 25 additions & 57 deletions packages/next-swc/crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,66 +363,34 @@ pub async fn get_client_runtime_entries(
execution_context: Vc<ExecutionContext>,
) -> Result<Vc<RuntimeEntries>> {
let mut runtime_entries = vec![];
let resolve_options_context =
get_client_resolve_options_context(project_root, ty, mode, next_config, execution_context);

match mode {
NextMode::Development => {
let resolve_options_context = get_client_resolve_options_context(
project_root,
ty,
mode,
next_config,
execution_context,
);
let enable_react_refresh =
assert_can_resolve_react_refresh(project_root, resolve_options_context)
.await?
.as_request();
if matches!(mode, NextMode::Development) {
let enable_react_refresh =
assert_can_resolve_react_refresh(project_root, resolve_options_context)
.await?
.as_request();

// It's important that React Refresh come before the regular bootstrap file,
// because the bootstrap contains JSX which requires Refresh's global
// functions to be available.
if let Some(request) = enable_react_refresh {
runtime_entries
.push(RuntimeEntry::Request(request, project_root.join("_".to_string())).cell())
};
// It's important that React Refresh come before the regular bootstrap file,
// because the bootstrap contains JSX which requires Refresh's global
// functions to be available.
if let Some(request) = enable_react_refresh {
runtime_entries
.push(RuntimeEntry::Request(request, project_root.join("_".to_string())).cell())
};
}

if matches!(*ty, ClientContextType::App { .. },) {
runtime_entries.push(
RuntimeEntry::Request(
Request::parse(Value::new(Pattern::Constant(
"next/dist/client/app-next-dev-turbopack.js".to_string(),
))),
project_root.join("_".to_string()),
)
.cell(),
);
}
}
NextMode::Build => match *ty {
ClientContextType::App { .. } => {
runtime_entries.push(
RuntimeEntry::Request(
Request::parse(Value::new(Pattern::Constant(
"./build/client/app-bootstrap.ts".to_string(),
))),
next_js_fs().root().join("_".to_string()),
)
.cell(),
);
}
ClientContextType::Pages { .. } => {
runtime_entries.push(
RuntimeEntry::Request(
Request::parse(Value::new(Pattern::Constant(
"./build/client/bootstrap.ts".to_string(),
))),
next_js_fs().root().join("_".to_string()),
)
.cell(),
);
}
_ => {}
},
if matches!(*ty, ClientContextType::App { .. },) {
runtime_entries.push(
RuntimeEntry::Request(
Request::parse(Value::new(Pattern::Constant(
"next/dist/client/app-next-turbopack.js".to_string(),
))),
project_root.join("_".to_string()),
)
.cell(),
);
}

Ok(Vc::cell(runtime_entries))
Expand Down
24 changes: 4 additions & 20 deletions packages/next-swc/crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use turbopack_binding::{
},
environment::{Environment, ExecutionEnvironment, NodeJsEnvironment, RuntimeVersions},
free_var_references,
resolve::{parse::Request, pattern::Pattern},
},
ecmascript::{references::esm::UrlRewriteBehavior, TreeShakingMode},
ecmascript_plugin::transform::directives::client::ClientDirectiveTransformer,
Expand Down Expand Up @@ -44,7 +43,7 @@ use crate::{
embed_js::next_js_fs,
mode::NextMode,
next_build::{get_external_next_compiled_package_mapping, get_postcss_package_mapping},
next_client::{RuntimeEntries, RuntimeEntry},
next_client::RuntimeEntries,
next_config::NextConfig,
next_import_map::{get_next_server_import_map, mdx_import_source_file},
next_server::resolve::ExternalPredicate,
Expand Down Expand Up @@ -721,25 +720,10 @@ pub fn get_build_module_options_context() -> Vc<ModuleOptionsContext> {

#[turbo_tasks::function]
pub fn get_server_runtime_entries(
ty: Value<ServerContextType>,
mode: NextMode,
_ty: Value<ServerContextType>,
_mode: NextMode,
) -> Vc<RuntimeEntries> {
let mut runtime_entries = vec![];

if matches!(mode, NextMode::Build) {
if let ServerContextType::AppRSC { .. } = ty.into_value() {
runtime_entries.push(
RuntimeEntry::Request(
Request::parse(Value::new(Pattern::Constant(
"./build/server/app-bootstrap.ts".to_string(),
))),
next_js_fs().root().join("_".to_string()),
)
.cell(),
);
}
}

let runtime_entries = vec![];
Vc::cell(runtime_entries)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ window.next.version += '-turbo'
;(self as any).__webpack_hash__ = ''

appBootstrap(() => {
require('./app-turbopack')
const { hydrate } = require('./app-index')
hydrate()
})
Expand Down
4 changes: 0 additions & 4 deletions packages/next/src/client/app-turbopack.ts

This file was deleted.

0 comments on commit 079fe54

Please sign in to comment.