Unverified Commit 8f2b38c1 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

turbopack: experimental minify-before-chunking feature

Minification happens on a per-chunk basis. With enough chunks, we get good
parallelization, but a large chunk can create a single large span that
wastes unused cores.
This flag makes minification more granular, applying it to each module and
caching the result. The goal is to make each minification step smaller, so
that they can be evenly distributed across parallel workers.
Theoretically this may also reduce the work done on a re-build, since the
minification transform will only be applied to changed modules.

The flag is configured behind an `experimental` config flag, and only
applies to builds (because we don't minify in dev!).

An ideal outcome is equal-or-faster builds, with almost no change to
byte size. I don't expect much change to byte size, becuase the shape
of our chunks doesn't lend itself to cross-module optimizations, but
it's entirely possible we regress this a bit. That hypothesis will
need to be tested against our benchmark suite of real Next apps.
Co-authored-by: 's avatarAndrew Imm <andrew.imm@vercel.com>
Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent bd824641
......@@ -1733,6 +1733,9 @@ impl Project {
source_maps: self.next_config().client_source_maps(self.next_mode()),
no_mangling: self.no_mangling(),
scope_hoisting: self.next_config().turbo_scope_hoisting(self.next_mode()),
minify_before_chunking: self
.next_config()
.turbopack_minify_before_chunking(self.next_mode()),
nested_async_chunking: self
.next_config()
.turbo_nested_async_chunking(self.next_mode(), true),
......
......@@ -494,6 +494,7 @@ pub struct ClientChunkingContextOptions {
pub source_maps: Vc<SourceMapsType>,
pub no_mangling: Vc<bool>,
pub scope_hoisting: Vc<bool>,
pub minify_before_chunking: Vc<bool>,
pub nested_async_chunking: Vc<bool>,
pub shared_runtime: Vc<bool>,
pub per_page_module_graph: Vc<bool>,
......@@ -544,6 +545,7 @@ pub async fn get_client_chunking_context(
source_maps,
no_mangling,
scope_hoisting,
minify_before_chunking,
nested_async_chunking,
shared_runtime,
per_page_module_graph,
......@@ -656,6 +658,7 @@ pub async fn get_client_chunking_context(
)
.chunk_content_hashing(ContentHashing::Direct { length: 13 })
.module_merging(*scope_hoisting.await?)
.minify_before_chunking(*minify_before_chunking.await?)
.shared_runtime(*shared_runtime.await?);
}
......
......@@ -1196,6 +1196,7 @@ pub struct ExperimentalConfig {
turbopack_input_source_maps: Option<bool>,
turbopack_module_fragments: Option<bool>,
turbopack_scope_hoisting: Option<bool>,
turbopack_minify_before_chunking: Option<bool>,
turbopack_shared_runtime: Option<bool>,
/// Custom URL prefix for Web Worker URLs (the entrypoint and the module
/// chunks loaded inside the worker) produced by
......@@ -2502,6 +2503,19 @@ impl NextConfig {
}))
}
/// Whether to minify each module factory as it is generated rather than minifying each
/// finished chunk in one pass. Disabled in development, where nothing is minified anyway.
#[turbo_tasks::function]
pub async fn turbopack_minify_before_chunking(&self, mode: Vc<NextMode>) -> Result<Vc<bool>> {
Ok(Vc::cell(match *mode.await? {
NextMode::Development => false,
NextMode::Build => self
.experimental
.turbopack_minify_before_chunking
.unwrap_or(false),
}))
}
#[turbo_tasks::function]
pub fn turbopack_generate_component_chunks(&self) -> Vc<bool> {
Vc::cell(
......
......@@ -432,6 +432,7 @@ export const experimentalSchema = {
turbopackRemoveUnusedImports: z.boolean().optional(),
turbopackRemoveUnusedExports: z.boolean().optional(),
turbopackScopeHoisting: z.boolean().optional(),
turbopackMinifyBeforeChunking: z.boolean().optional(),
turbopackSharedRuntime: z.boolean().optional(),
turbopackChunking: z
.object({
......
......@@ -891,6 +891,21 @@ export interface ExperimentalConfig {
*/
turbopackScopeHoisting?: boolean
/**
* Minify each module factory as it is generated, instead of minifying each finished chunk in
* one pass. Defaults to false. Always disabled in development mode, where nothing is minified.
*
* A chunk is a single top-level statement holding every module factory, so minifying the
* finished chunk cannot be split across cores and becomes a serial tail at the end of a build.
* Minifying per factory spreads that work across the task pool, and lets each factory's
* minified output be cached so an incremental build only re-minifies what changed.
*
* The trade-off is marginally larger output: a factory cannot see the strict wrapper the chunk
* will place it in, and optimizations that require seeing every factory at once are not
* performed.
*/
turbopackMinifyBeforeChunking?: boolean
/**
* Share the browser runtime across routes in a single `runtime.js` asset and inline the
* per-route chunk-group bootstrap into the HTML, dropping the per-route runtime. Defaults to
......
......@@ -142,6 +142,12 @@ impl BrowserChunkingContextBuilder {
self
}
/// EXPERIMENTAL. See [`ChunkingContext::minify_before_chunking`].
pub fn minify_before_chunking(mut self, minify_before_chunking: bool) -> Self {
self.chunking_context.minify_before_chunking = minify_before_chunking;
self
}
pub fn source_maps(mut self, source_maps: SourceMapsType) -> Self {
self.chunking_context.source_maps_type = source_maps;
self
......@@ -374,6 +380,9 @@ pub struct BrowserChunkingContext {
runtime_type: RuntimeType,
/// Whether to minify resulting chunks
minify_type: MinifyType,
/// EXPERIMENTAL: minify each chunk item before the chunk is assembled, rather than minifying
/// the finished chunk. See [`ChunkingContext::minify_before_chunking`].
minify_before_chunking: bool,
/// Whether content hashing is enabled for chunk filenames.
chunk_content_hashing: Option<ContentHashing>,
/// Content hashing for asset filenames.
......@@ -451,6 +460,7 @@ impl BrowserChunkingContext {
environment,
runtime_type,
minify_type: MinifyType::NoMinify,
minify_before_chunking: false,
chunk_content_hashing: None,
asset_content_hashing: ContentHashing::Direct { length: 13 },
source_maps_type: SourceMapsType::Full,
......@@ -869,6 +879,11 @@ impl ChunkingContext for BrowserChunkingContext {
self.minify_type.cell()
}
#[turbo_tasks::function]
fn minify_before_chunking(&self) -> Vc<bool> {
Vc::cell(self.minify_before_chunking)
}
#[turbo_tasks::function]
fn should_use_absolute_url_references(&self) -> Vc<bool> {
Vc::cell(self.should_use_absolute_url_references)
......
......@@ -95,7 +95,21 @@ impl EcmascriptBrowserChunkContent {
.supports_arrow_functions()
.await?;
let content = this.content.await?;
let chunk_items = content.chunk_item_code_module_ids_and_paths().await?;
let minify_type = *this.chunking_context.minify_type().await?;
// Either each factory is minified now, in parallel and cached per item, or the assembled
// chunk is minified in one pass below — never both.
let minify_before_chunking = *this.chunking_context.minify_before_chunking().await?
&& matches!(minify_type, MinifyType::Minify { .. });
let chunk_items = content
.chunk_item_code_module_ids_and_paths(
if minify_before_chunking {
minify_type
} else {
MinifyType::NoMinify
},
source_maps,
)
.await?;
let strict_factory_mode = strict_factory_mode(&chunk_items, supports_arrow_functions);
let strict_chunk_wrapper =
......@@ -133,7 +147,7 @@ impl EcmascriptBrowserChunkContent {
let mut code = code.build();
if let MinifyType::Minify { mangle } = *this.chunking_context.minify_type().await? {
if !minify_before_chunking && let MinifyType::Minify { mangle } = minify_type {
code = minify(code, source_maps, mangle)?;
}
......
......@@ -451,6 +451,22 @@ pub trait ChunkingContext {
MinifyType::NoMinify.cell()
}
/// EXPERIMENTAL: minify each chunk item on its own, before the chunk is assembled, instead of
/// minifying the finished chunk in one pass.
///
/// A chunk is a single top-level statement holding every module factory, so the whole-chunk
/// pass cannot be parallelised and becomes a serial tail at the end of the build. Minifying
/// per item spreads that work across the task pool and lets each item's minified output be
/// cached, so an incremental build only re-minifies what changed.
///
/// The trade-off is slightly larger output: a factory cannot see the strict wrapper the chunk
/// will place it in, so it keeps its own `"use strict"` directive, and no optimisation that
/// requires seeing every factory at once is performed.
#[turbo_tasks::function]
fn minify_before_chunking(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false)
}
#[turbo_tasks::function]
fn should_use_absolute_url_references(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false)
......
......@@ -6,25 +6,39 @@ use turbo_tasks::{
NonLocalValue, ReadRef, TryJoinIterExt, ValueToString, Vc, debug::ValueDebugFormat,
};
use turbopack_core::{
chunk::{ChunkItem, ChunkItemExt, ModuleId},
chunk::{ChunkItem, ChunkItemExt, MinifyType, ModuleId},
code_builder::Code,
};
use crate::chunk::{
EcmascriptChunkItemBatchGroup, EcmascriptChunkItemExt, EcmascriptChunkItemOrBatchWithAsyncInfo,
EcmascriptChunkItemWithAsyncInfo,
use crate::{
chunk::{
EcmascriptChunkItemBatchGroup, EcmascriptChunkItemExt,
EcmascriptChunkItemOrBatchWithAsyncInfo, EcmascriptChunkItemWithAsyncInfo,
},
minify::minify_chunk_item,
};
async fn code_module_id_and_path(
item: &EcmascriptChunkItemWithAsyncInfo,
minify: MinifyType,
source_maps: bool,
) -> Result<CodeModuleIdAndPath> {
let factory = item
.chunk_item
.code(item.async_info.map(|info| *info))
.await?;
let code = factory.code.to_code().await?;
// `MinifyType::NoMinify` here means the chunk will be minified as a whole later (or not at
// all); only the per-item mode asks for the factory to be minified now.
let code = match minify {
MinifyType::Minify { mangle } => {
ReadRef::new_owned(minify_chunk_item(&code, source_maps, mangle)?)
}
MinifyType::NoMinify => code,
};
Ok(CodeModuleIdAndPath {
id: item.chunk_item.id().await?,
code: factory.code.to_code().await?,
code,
path: item.chunk_item.asset_ident().to_string().owned().await?,
strict: factory.strict,
})
......@@ -49,6 +63,8 @@ pub struct BatchGroupCodeModuleIdsAndPaths(
#[turbo_tasks::function]
pub async fn batch_group_code_module_ids_and_paths(
batch_group: Vc<EcmascriptChunkItemBatchGroup>,
minify: MinifyType,
source_maps: bool,
) -> Result<Vc<BatchGroupCodeModuleIdsAndPaths>> {
Ok(Vc::cell(
batch_group
......@@ -58,7 +74,7 @@ pub async fn batch_group_code_module_ids_and_paths(
.map(async |item| {
Ok((
item.clone(),
item_code_module_ids_and_paths(item.clone()).await?,
item_code_module_ids_and_paths(item.clone(), minify, source_maps).await?,
))
})
.try_join()
......@@ -71,16 +87,18 @@ pub async fn batch_group_code_module_ids_and_paths(
#[turbo_tasks::function]
pub async fn item_code_module_ids_and_paths(
item: EcmascriptChunkItemOrBatchWithAsyncInfo,
minify: MinifyType,
source_maps: bool,
) -> Result<Vc<CodeModuleIdsAndPaths>> {
Ok(Vc::cell(match item {
EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(item) => {
smallvec![code_module_id_and_path(&item).await?]
smallvec![code_module_id_and_path(&item, minify, source_maps).await?]
}
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch
.await?
.chunk_items
.iter()
.map(code_module_id_and_path)
.map(async |item| code_module_id_and_path(item, minify, source_maps).await)
.try_join()
.await?
.into(),
......
......@@ -3,7 +3,7 @@ use std::future::IntoFuture;
use anyhow::Result;
use either::Either;
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbopack_core::chunk::{ChunkItem, ChunkItems, batch_info};
use turbopack_core::chunk::{ChunkItem, ChunkItems, MinifyType, batch_info};
use crate::chunk::{
CodeModuleIdAndPath,
......@@ -49,12 +49,18 @@ impl EcmascriptChunkContent {
}
impl EcmascriptChunkContent {
pub async fn chunk_item_code_module_ids_and_paths(&self) -> Result<Vec<CodeModuleIdAndPath>> {
/// `minify` is `Minify` only when the chunking context asked for per-item minification;
/// otherwise the chunk is minified as a whole afterwards and this must stay `NoMinify`.
pub async fn chunk_item_code_module_ids_and_paths(
&self,
minify: MinifyType,
source_maps: bool,
) -> Result<Vec<CodeModuleIdAndPath>> {
let chunk_item_groups = batch_info(
&self.batch_groups,
&self.chunk_items,
|batch| batch_group_code_module_ids_and_paths(batch).into_future(),
|item| item_code_module_ids_and_paths(item.clone()).into_future(),
|batch| batch_group_code_module_ids_and_paths(batch, minify, source_maps).into_future(),
|item| item_code_module_ids_and_paths(item.clone(), minify, source_maps).into_future(),
)
.await?;
let mut chunk_items = chunk_item_groups
......
......@@ -204,3 +204,227 @@ fn print_program(
Ok((src, src_map_buf))
}
/// Name the chunk item expression is assigned to while it is minified. It is never emitted: the
/// assignment exists only so the compressor sees a statement with observable side effects and
/// does not discard the factory as an unused expression. An undeclared global is used because
/// the mangler leaves unresolved names alone.
const CHUNK_ITEM_SENTINEL: &str = "__TURBOPACK_CHUNK_ITEM__";
/// Minify a single chunk item — one module factory expression — rather than the assembled chunk.
///
/// A browser chunk is a single top-level statement (one `.push([...])` call holding every module
/// factory), so minifying the finished chunk cannot be split across cores: SWC parallelises
/// statement lists, and there is only ever one statement. Minifying each factory separately makes
/// the work embarrassingly parallel, and lets turbo-tasks cache it per item so an incremental
/// build only re-minifies the factories that changed.
///
/// This is sound because each factory is its own function scope, so the compressor has no
/// cross-factory optimisations available to it in the first place. Two consequences are worth
/// knowing:
///
/// * Output is marginally larger. A factory inside a strict wrapper keeps its own `"use strict"`
/// directive, because a per-item pass cannot see the wrapper the chunk will place it in.
/// * Whole-chunk passes that depend on seeing every factory at once are not performed.
///
/// The factory is wrapped in a synthetic assignment at the AST level rather than by prepending
/// text to the source. Prepending would shift every column on the first line and invalidate the
/// item's existing source map; the synthetic nodes carry `DUMMY_SP` and contribute no mappings,
/// so the parsed expression keeps the spans it was parsed with.
#[instrument(level = "info", name = "minify chunk item", skip_all)]
pub fn minify_chunk_item(
code: &Code,
source_maps: bool,
mangle: Option<MangleType>,
) -> Result<Code> {
use swc_core::{
common::DUMMY_SP,
ecma::ast::{
AssignExpr, AssignOp, AssignTarget, Expr, ExprStmt, Ident, Script, SimpleAssignTarget,
Stmt,
},
};
let original_map = source_maps.then(|| code.generate_source_map_ref(None));
let generate_debug_id = code.should_generate_debug_id();
let source_code = BytesStr::from_utf8(code.source_code().clone().into_bytes())?;
let cm = Arc::new(SwcSourceMap::new(FilePathMapping::empty()));
let fm = cm.new_source_file(FileName::Anon.into(), source_code);
let comments = SingleThreadedComments::default();
let lexer = Lexer::new(
Syntax::default(),
EsVersion::latest(),
StringInput::from(&*fm),
Some(&comments),
);
let mut parser = Parser::new_from(lexer);
let (minified, src_map_buf, source_map_names) =
try_with_handler(cm.clone(), Default::default(), |handler| {
GLOBALS.set(&Default::default(), || {
let expr = match parser.parse_expr() {
Ok(expr) => expr,
Err(err) => {
err.into_diagnostic(handler).emit();
bail!("failed to parse chunk item\n{}", fm.src)
}
};
let source_map_names = if original_map.is_some() {
let mut collector = IdentCollector::default();
expr.visit_with(&mut collector);
collector.into_map()
} else {
Default::default()
};
let unresolved_mark = Mark::new();
let top_level_mark = Mark::new();
let program = Program::Script(Script {
span: DUMMY_SP,
body: vec![Stmt::Expr(ExprStmt {
span: DUMMY_SP,
expr: Box::new(Expr::Assign(AssignExpr {
span: DUMMY_SP,
op: AssignOp::Assign,
left: AssignTarget::Simple(SimpleAssignTarget::Ident(
Ident::new_no_ctxt(CHUNK_ITEM_SENTINEL.into(), DUMMY_SP).into(),
)),
right: expr,
})),
})],
shebang: None,
});
let program = program.apply(paren_remover(Some(&comments)));
let program = program.apply(swc_core::ecma::transforms::base::resolver(
unresolved_mark,
top_level_mark,
false,
));
let mut program = swc_core::ecma::minifier::optimize(
program,
cm.clone(),
Some(&comments),
None,
&MinifyOptions {
compress: Some(CompressOptions {
// Match `minify`: 2 passes rather than the default 3.
passes: 2,
keep_classnames: mangle.is_none(),
keep_fnames: mangle.is_none(),
..Default::default()
}),
mangle: mangle.map(|mangle| {
let reserved = vec![atom!("AbortSignal")];
match mangle {
MangleType::OptimalSize => MangleOptions {
reserved,
..Default::default()
},
MangleType::Deterministic => MangleOptions {
reserved,
disable_char_freq: true,
..Default::default()
},
}
}),
..Default::default()
},
&ExtraOptions {
top_level_mark,
unresolved_mark,
mangle_name_cache: None,
},
);
if mangle.is_none() {
program.mutate(hygiene_with_config(hygiene::Config {
top_level_mark,
..Default::default()
}));
}
let program = program.apply(ecma::transforms::base::fixer::fixer(Some(
&comments as &dyn Comments,
)));
// Unwrap the sentinel assignment and emit only the factory expression, so the
// result can be spliced back into the chunk's array. Emitting it as a statement
// would turn a `function (…) {}` factory into a declaration.
let factory = take_sentinel_rhs(program).context(
"chunk item minification lost its sentinel assignment; the compressor rewrote \
the wrapper unexpectedly",
)?;
let (src, src_map_buf) = print_expr(cm.clone(), &factory, original_map.is_some())?;
Ok((src, src_map_buf, source_map_names))
})
})
.map_err(|e| e.to_pretty_error())?;
let mut builder = CodeBuilder::new(original_map.is_some(), generate_debug_id);
if let Some(original_map) = original_map.as_ref() {
let mut src_map_buf = src_map_buf;
src_map_buf.shrink_to_fit();
builder.push_source(
&minified.into(),
Some(generate_js_source_map(
&*cm,
src_map_buf,
Some(original_map),
true,
false,
source_map_names,
)?),
);
} else {
builder.push_source(&minified.into(), None::<turbo_tasks_fs::rope::Rope>);
}
Ok(builder.build())
}
/// Pull the right-hand side back out of the synthetic `SENTINEL = <factory>` wrapper.
fn take_sentinel_rhs(program: Program) -> Option<Box<swc_core::ecma::ast::Expr>> {
use swc_core::ecma::ast::{Expr, Stmt};
let Program::Script(script) = program else {
return None;
};
let [Stmt::Expr(stmt)] = script.body.as_slice() else {
return None;
};
let Expr::Assign(assign) = &*stmt.expr else {
return None;
};
Some(assign.right.clone())
}
/// Emit a bare expression, mirroring [`print_program`]'s writer configuration.
fn print_expr(
cm: Arc<SwcSourceMap>,
expr: &swc_core::ecma::ast::Expr,
source_maps: bool,
) -> Result<(String, Vec<(BytePos, LineCol)>)> {
use swc_core::ecma::codegen::Node;
let mut src_map_buf = vec![];
let mut buf = vec![];
{
let wr = Box::new(text_writer::omit_trailing_semi(Box::new(JsWriter::new(
cm.clone(),
"\n",
&mut buf,
source_maps.then_some(&mut src_map_buf),
)))) as Box<dyn WriteJs>;
let mut emitter = Emitter {
cfg: swc_core::ecma::codegen::Config::default().with_minify(true),
comments: None,
cm: cm.clone(),
wr,
};
expr.emit_with(&mut emitter)
.context("failed to emit chunk item")?;
}
Ok((String::from_utf8(buf)?, src_map_buf))
}
......@@ -69,7 +69,21 @@ impl EcmascriptNodeChunkContent {
.supports_arrow_functions()
.await?;
let content = self.content.await?;
let chunk_items = content.chunk_item_code_module_ids_and_paths().await?;
let minify_type = *self.chunking_context.minify_type().await?;
// Either each factory is minified now, in parallel and cached per item, or the assembled
// chunk is minified in one pass below — never both.
let minify_before_chunking = *self.chunking_context.minify_before_chunking().await?
&& matches!(minify_type, MinifyType::Minify { .. });
let chunk_items = content
.chunk_item_code_module_ids_and_paths(
if minify_before_chunking {
minify_type
} else {
MinifyType::NoMinify
},
source_maps,
)
.await?;
let strict_factory_mode = strict_factory_mode(&chunk_items, supports_arrow_functions);
let strict_chunk_wrapper =
......@@ -91,7 +105,7 @@ impl EcmascriptNodeChunkContent {
let mut code = code.build();
if let MinifyType::Minify { mangle } = *self.chunking_context.minify_type().await? {
if !minify_before_chunking && let MinifyType::Minify { mangle } = minify_type {
code = minify(code, source_maps, mangle)?;
}
......
......@@ -80,6 +80,9 @@ struct SnapshotOptions {
entry: String,
#[serde(default = "default_minify_type")]
minify_type: MinifyType,
/// EXPERIMENTAL: minify each chunk item before assembling the chunk.
#[serde(default)]
minify_before_chunking: bool,
#[serde(default)]
runtime: Runtime,
#[serde(default = "default_runtime_type")]
......@@ -140,6 +143,7 @@ impl Default for SnapshotOptions {
browserslist: default_browserslist(),
entry: default_entry(),
minify_type: default_minify_type(),
minify_before_chunking: false,
runtime: Default::default(),
runtime_type: default_runtime_type(),
environment: Default::default(),
......@@ -541,6 +545,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
options.runtime_type,
)
.minify_type(options.minify_type)
.minify_before_chunking(options.minify_before_chunking)
.module_merging(options.scope_hoisting)
.shared_runtime(options.shared_runtime)
.export_usage(if options.remove_unused_exports {
......
export function double(value) {
const doubled = value * 2
return doubled
}
export function unusedExport() {
return 'this should compress away'
}
import { double } from './helper'
function unusedInEntry(a, b) {
const neverRead = a + b
return a * b
}
console.log(double(21))
{
"runtime": "NodeJs",
"minifyType": {
"Minify": {
"mangle": "optimal-size"
}
},
"minifyBeforeChunking": true
}
(()=>{"use strict";module.exports=["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/helper.js [test] (ecmascript)",t=>{function s(t){return 2*t}function e(){return"this should compress away"}t.s(["double",()=>s,"unusedExport",()=>e])},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/index.js [test] (ecmascript)",t=>{t.s([]),console.log((0,t.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/helper.js [test] (ecmascript)").double)(21))}]})();
//# sourceMappingURL=1jsg_tests_snapshot_basic_ecmascript_minify_before_chunking_input_0ha5_3_s63fqt._.js.map
\ No newline at end of file
{"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/helper.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/index.js"],"sourcesContent":["export function double(value) {\n const doubled = value * 2;\n return doubled;\n}\n\nexport function unusedExport() {\n return \"this should compress away\";\n}\n","import { double } from \"./helper\";\n\nfunction unusedInEntry(a, b) {\n const neverRead = a + b;\n return a * b;\n}\n\nconsole.log(double(21));\n"],"names":["double","value","doubled","unusedExport","unusedInEntry","a","b","neverRead","console","log"],"mappings":"+KAAO,SAASA,EAAOC,CAAK,EAE1B,OADgBA,AAAQ,AACjBC,GACT,CAEO,SAASC,IACd,MAAO,2BACT,gMCAAK,QAAQC,GAAG,CAAC,CAAA,EAPZ,AAOY,EAPZ,CAAA,CAAA,yIAOY,MAAA,AAAM,EAAC"}
\ No newline at end of file
var RUNTIME_PUBLIC_PATH = "output/[turbopack]_runtime.js";
var RELATIVE_ROOT_PATH = "../../../../../../..";
var ASSET_PREFIX = "/";
// Dummy runtime
\ No newline at end of file
var R=require("./[turbopack]_runtime.js")("output/index.entry.js")
R.c("output/1jsg_tests_snapshot_basic_ecmascript_minify_before_chunking_input_0ha5_3_s63fqt._.js")
R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/index.js [test] (ecmascript)")
module.exports=R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking/input/index.js [test] (ecmascript)").exports
\ No newline at end of file
// Sloppy-mode CJS: octal literals are a syntax error under "use strict".
var legacy = 0777
module.exports.cjsValue = legacy
export const esmValue = (function () {
const computed = 1 + 1
return computed
})()
import { esmValue } from './esm-mod'
const cjs = require('./cjs-mod')
console.log(esmValue, cjs.cjsValue)
{
"runtime": "NodeJs",
"minifyType": {
"Minify": {
"mangle": "optimal-size"
}
},
"minifyBeforeChunking": true
}
module.exports=["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/cjs-mod.js [test] (ecmascript)",(t,s,e)=>{s.exports.cjsValue=511},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/esm-mod.js [test] (ecmascript)",t=>{"use strict";t.s(["esmValue",()=>s]);let s=2},"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/index.js [test] (ecmascript)",t=>{"use strict";t.s([]);var s=t.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/esm-mod.js [test] (ecmascript)");let e=t.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/cjs-mod.js [test] (ecmascript)");console.log(s.esmValue,e.cjsValue)}];
//# sourceMappingURL=0p5q_snapshot_basic_ecmascript_minify_before_chunking_mixed_input_1uae3zs7l497e._.js.map
\ No newline at end of file
{"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/cjs-mod.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/esm-mod.js","turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/index.js"],"sourcesContent":["// Sloppy-mode CJS: octal literals are a syntax error under \"use strict\".\nvar legacy = 0777;\nmodule.exports.cjsValue = legacy;\n","export const esmValue = (function () {\n const computed = 1 + 1;\n return computed;\n})();\n","import { esmValue } from \"./esm-mod\";\nconst cjs = require(\"./cjs-mod\");\nconsole.log(esmValue, cjs.cjsValue);\n"],"names":["legacy","module","exports","cjsValue","esmValue","computed","cjs","console","log"],"mappings":"yKAEAC,EAAOC,OAAO,CAACC,QAAQ,CADV,EACaH,2LCFnB,IAAMI,EACM,IAAI,KADC,AAAC,gKCAzB,IAAA,EAAA,EAAA,CAAA,CAAA,gJACA,IAAME,EAAAA,EAAAA,CAAAA,CAAAA,gJACNC,QAAQC,GAAG,CAAC,EAAA,QAAQ,CAAEF,EAAIH,QAAQ"}
\ No newline at end of file
var RUNTIME_PUBLIC_PATH = "output/[turbopack]_runtime.js";
var RELATIVE_ROOT_PATH = "../../../../../../..";
var ASSET_PREFIX = "/";
// Dummy runtime
\ No newline at end of file
var R=require("./[turbopack]_runtime.js")("output/index.entry.js")
R.c("output/0p5q_snapshot_basic_ecmascript_minify_before_chunking_mixed_input_1uae3zs7l497e._.js")
R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/index.js [test] (ecmascript)")
module.exports=R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/ecmascript_minify_before_chunking_mixed/input/index.js [test] (ecmascript)").exports
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment