Unverified Commit 605425e1 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: rename to use turbopack: no side effects (#94427)

Consistent naming:
- `"use turbopack no side effects"`
- `"use turbopack: constants"`
parent e3a78fd3
......@@ -2743,7 +2743,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
ServerActionsMode::Turbopack => {
new.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt {
expr: Box::new(Expr::Lit(Lit::Str(
atom!("use turbopack no side effects").into(),
atom!("use turbopack: no side effects").into(),
))),
span: DUMMY_SP,
})));
......@@ -2752,7 +2752,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
let mut module_items = vec![
ModuleItem::Stmt(Stmt::Expr(ExprStmt {
expr: Box::new(Expr::Lit(Lit::Str(
atom!("use turbopack no side effects").into(),
atom!("use turbopack: no side effects").into(),
))),
span: DUMMY_SP,
})),
......
"use turbopack no side effects";
export { foo } from "data:text/javascript,%2F%2A%20__next_internal_action_entry_do_not_use__%20%5B%7B%2200ab21efdafbe611287bc25c0462b1e0510d13e48b%22%3A%7B%22name%22%3A%22foo%22%7D%7D%2C%22%2Fapp%2Fitem.js%22%2C%22%22%5D%20%2A%2F%22use%20turbopack%20no%20side%20effects%22%3Bimport%7BcreateServerReference%2CcallServer%2CfindSourceMapURL%7Dfrom%22private-next-rsc-action-client-wrapper%22%3Bconst%20%24%24RSC_SERVER_ACTION_0%3D%2F%2A%23__PURE__%2A%2FcreateServerReference%28%2200ab21efdafbe611287bc25c0462b1e0510d13e48b%22%2CcallServer%2Cvoid%200%2CfindSourceMapURL%2C%22foo%22%29%3Bexport%7B%24%24RSC_SERVER_ACTION_0%20as%20foo%7D%3B";
export { bar } from "data:text/javascript,%2F%2A%20__next_internal_action_entry_do_not_use__%20%5B%7B%2200ac840dcaf5e8197cb02b7f3a43c119b7a770b272%22%3A%7B%22name%22%3A%22bar%22%7D%7D%2C%22%2Fapp%2Fitem.js%22%2C%22%22%5D%20%2A%2F%22use%20turbopack%20no%20side%20effects%22%3Bimport%7BcreateServerReference%2CcallServer%2CfindSourceMapURL%7Dfrom%22private-next-rsc-action-client-wrapper%22%3Bconst%20%24%24RSC_SERVER_ACTION_1%3D%2F%2A%23__PURE__%2A%2FcreateServerReference%28%2200ac840dcaf5e8197cb02b7f3a43c119b7a770b272%22%2CcallServer%2Cvoid%200%2CfindSourceMapURL%2C%22bar%22%29%3Bexport%7B%24%24RSC_SERVER_ACTION_1%20as%20bar%7D%3B";
"use turbopack: no side effects";
export { foo } from "data:text/javascript,%2F%2A%20__next_internal_action_entry_do_not_use__%20%5B%7B%2200ab21efdafbe611287bc25c0462b1e0510d13e48b%22%3A%7B%22name%22%3A%22foo%22%7D%7D%2C%22%2Fapp%2Fitem.js%22%2C%22%22%5D%20%2A%2F%22use%20turbopack%3A%20no%20side%20effects%22%3Bimport%7BcreateServerReference%2CcallServer%2CfindSourceMapURL%7Dfrom%22private-next-rsc-action-client-wrapper%22%3Bconst%20%24%24RSC_SERVER_ACTION_0%3D%2F%2A%23__PURE__%2A%2FcreateServerReference%28%2200ab21efdafbe611287bc25c0462b1e0510d13e48b%22%2CcallServer%2Cvoid%200%2CfindSourceMapURL%2C%22foo%22%29%3Bexport%7B%24%24RSC_SERVER_ACTION_0%20as%20foo%7D%3B";
export { bar } from "data:text/javascript,%2F%2A%20__next_internal_action_entry_do_not_use__%20%5B%7B%2200ac840dcaf5e8197cb02b7f3a43c119b7a770b272%22%3A%7B%22name%22%3A%22bar%22%7D%7D%2C%22%2Fapp%2Fitem.js%22%2C%22%22%5D%20%2A%2F%22use%20turbopack%3A%20no%20side%20effects%22%3Bimport%7BcreateServerReference%2CcallServer%2CfindSourceMapURL%7Dfrom%22private-next-rsc-action-client-wrapper%22%3Bconst%20%24%24RSC_SERVER_ACTION_1%3D%2F%2A%23__PURE__%2A%2FcreateServerReference%28%2200ac840dcaf5e8197cb02b7f3a43c119b7a770b272%22%2CcallServer%2Cvoid%200%2CfindSourceMapURL%2C%22bar%22%29%3Bexport%7B%24%24RSC_SERVER_ACTION_1%20as%20bar%7D%3B";
......@@ -23,7 +23,7 @@ pub enum ModuleSideEffects {
/// configuration.
///
/// ```js
/// "use turbopack no side effects"
/// "use turbopack: no side effects"
/// ```
///
/// This module might not even be parsed (and thus chunked) if no other module depends on any of
......
'use turbopack no side effects'
'use turbopack: no side effects'
// Evaluate the ES2024 feature check once at module load time.
const _fromBase64: ((s: string) => Uint8Array) | null =
......
......@@ -51,7 +51,7 @@ impl SourceTransform for BytesSourceTransform {
// Generate ES module that decodes base64 to Uint8Array with inline source map.
let code = format!(
r#""use turbopack no side effects";
r#""use turbopack: no side effects";
import {{ base64Decode }} from '@turbopack/base64';
export default base64Decode({});
{}"#,
......
......@@ -37,6 +37,8 @@ pub fn parse_module_turbopack_directives(program: &Program) -> TurbopackDirectiv
&& let Expr::Lit(Lit::Str(Str { value, .. })) = &*expr.expr
{
match &*value.to_string_lossy() {
"use turbopack: no side effects" => result.no_side_effects = true,
// Keep for backwards compatibility
"use turbopack no side effects" => result.no_side_effects = true,
"use turbopack: constants" => result.constants_module = true,
v if v.starts_with("use turbopack ") => {
......
......@@ -67,13 +67,13 @@ impl SourceTransform for JsonSourceTransform {
FileJsonContent::Content(data) => {
let data_str = data.to_string();
// The "use turbopack no side effects" directive marks this module as
// The "use turbopack: no side effects" directive marks this module as
// side-effect free for tree shaking
let mut code = String::with_capacity(
data_str.len() + 100, /* estimate to account for our `use` comment, export
* overhead and sourcemap comment */
);
code.push_str("\"use turbopack no side effects\";\n");
code.push_str("\"use turbopack: no side effects\";\n");
let rename_pattern = if this.use_esm {
// Spec-compliant ESM: only default export
......
......@@ -46,7 +46,7 @@ impl SourceTransform for TextSourceTransform {
// Generate ES module with inline source map pointing back to the original file.
let code = format!(
"\"use turbopack no side effects\";\nexport default {};\n{}",
"\"use turbopack: no side effects\";\nexport default {};\n{}",
StringifyJs(&text),
inline_source_map_comment(&ident.path.path, &text)
);
......
'use turbopack no side effects'
'use turbopack: no side effects'
export { foo } from './foo'
export { bar } from './bar'
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