Skip to main content

rolldown_ecmascript/
constants.rs

1use oxc::ast::ast::Str;
2use oxc_str::{Ident, static_ident};
3
4// Special global variable `exports` in CommonJS modules
5pub const CJS_EXPORTS_REF: &str = "exports";
6
7// Special global variable `module` in CommonJS modules
8pub const CJS_MODULE_REF: &str = "module";
9
10// Special global variable `require` in CommonJS modules
11pub const CJS_REQUIRE_REF: &str = "require";
12
13// Rolldown will rewrite `exports` in CommonJS modules to this.
14pub const CJS_ROLLDOWN_EXPORTS_REF: &str = "__rolldown_exports__";
15
16// Rolldown will rewrite `module` in CommonJS modules to this.
17pub const CJS_ROLLDOWN_MODULE_REF: &str = "__rolldown_module__";
18
19pub const CJS_EXPORTS_REF_STR: Str<'static> = Str::new_const(CJS_EXPORTS_REF);
20pub const CJS_MODULE_REF_STR: Str<'static> = Str::new_const(CJS_MODULE_REF);
21pub const CJS_REQUIRE_REF_STR: Str<'static> = Str::new_const(CJS_REQUIRE_REF);
22pub const CJS_ROLLDOWN_MODULE_REF_IDENT: Ident<'static> = static_ident!("__rolldown_module__");
23pub const CJS_ROLLDOWN_EXPORTS_REF_IDENT: Ident<'static> = static_ident!("__rolldown_exports__");