Skip to content

Commit

Permalink
feat: support binary loader (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkz authored Jun 8, 2024
1 parent c42b0e0 commit 8f2e07b
Show file tree
Hide file tree
Showing 36 changed files with 298 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/reusable-cargo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/rolldown/src/module_loader/module_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::task_result::NormalModuleTaskResult;
use super::Msg;
use crate::module_loader::runtime_normal_module_task::RuntimeNormalModuleTaskResult;
use crate::module_loader::task_context::TaskContext;
use crate::runtime::RuntimeModuleBrief;
use crate::runtime::{RuntimeModuleBrief, ROLLDOWN_RUNTIME_RESOURCE_ID};
use crate::types::symbols::Symbols;

use crate::{SharedOptions, SharedResolver};
Expand Down Expand Up @@ -109,7 +109,7 @@ impl ModuleLoader {
shared_context: common_data,
rx,
input_options,
visited: FxHashMap::default(),
visited: FxHashMap::from_iter([(ROLLDOWN_RUNTIME_RESOURCE_ID.into(), runtime_id.into())]),
runtime_id,
// runtime module is always there
remaining: 1,
Expand Down
14 changes: 13 additions & 1 deletion crates/rolldown/src/module_loader/normal_module_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use super::{task_context::TaskContext, Msg};
use crate::{
ast_scanner::{AstScanner, ScanResult},
module_loader::NormalModuleTaskResult,
runtime::ROLLDOWN_RUNTIME_RESOURCE_ID,
types::ast_symbols::AstSymbols,
utils::{
load_source::load_source, make_ast_symbol_and_scope::make_ast_scopes_and_symbols,
Expand Down Expand Up @@ -111,7 +112,7 @@ impl NormalModuleTask {
.await?
.into();

let mut ast = parse_to_ast(module_type, Arc::clone(&source))?;
let mut ast = parse_to_ast(&self.ctx.input_options, module_type, Arc::clone(&source))?;
tweak_ast_for_scanning(&mut ast);

let (scope, scan_result, ast_symbol, namespace_object_ref) = self.scan(&mut ast, &source);
Expand Down Expand Up @@ -269,6 +270,17 @@ impl NormalModuleTask {
}
}

// Check runtime module
if specifier == ROLLDOWN_RUNTIME_RESOURCE_ID {
return Ok(Ok(ResolvedRequestInfo {
path: specifier.to_string().into(),
module_type: ModuleDefFormat::EsmMjs,
is_external: false,
package_json: None,
side_effects: None,
}));
}

let resolved_id =
resolve_id(resolver, plugin_driver, specifier, Some(importer), options).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rolldown_oxc_utils::{OxcAst, OxcCompiler};
use super::Msg;
use crate::{
ast_scanner::{AstScanner, ScanResult},
runtime::RuntimeModuleBrief,
runtime::{RuntimeModuleBrief, ROLLDOWN_RUNTIME_RESOURCE_ID},
types::ast_symbols::AstSymbols,
utils::tweak_ast_for_scanning::tweak_ast_for_scanning,
};
Expand Down Expand Up @@ -61,8 +61,8 @@ impl RuntimeNormalModuleTask {
source,
id: self.module_id,
repr_name,
stable_resource_id: "rolldown:runtime".to_string(),
resource_id: ResourceId::new("rolldown:runtime"),
stable_resource_id: ROLLDOWN_RUNTIME_RESOURCE_ID.to_string(),
resource_id: ResourceId::new(ROLLDOWN_RUNTIME_RESOURCE_ID),
named_imports,
named_exports,
stmt_infos,
Expand All @@ -73,7 +73,7 @@ impl RuntimeNormalModuleTask {
exports_kind: ExportsKind::Esm,
namespace_object_ref,
def_format: ModuleDefFormat::EsmMjs,
debug_resource_id: "rolldown:runtime".to_string(),
debug_resource_id: ROLLDOWN_RUNTIME_RESOURCE_ID.to_string(),
exec_order: u32::MAX,
is_user_defined_entry: false,
import_records: IndexVec::default(),
Expand Down
64 changes: 41 additions & 23 deletions crates/rolldown/src/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ var __hasOwnProp = Object.prototype.hasOwnProperty
// compact one for minified code and a verbose one that generates friendly
// names in V8's profiler and in stack traces.
var __esm = (fn, res) => function () {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res
}
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res)
// Wraps a CommonJS closure and returns a require() function. This has two
// implementations, a compact one for minified code and a verbose one that
// generates friendly names in V8's profiler and in stack traces.
var __commonJS = (cb, mod) => function () {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports
}
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports)
// Used to implement ESM exports both for "require()" and "import * as"
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true })
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true })
}

var __copyProps = (to, from, except, desc) => {
if (from && typeof from === 'object' || typeof from === 'function')
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i]
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: (k => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
}
return to
if (from && typeof from === 'object' || typeof from === 'function')
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i]
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: (k => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
}
return to
}

// This is used to implement "export * from" statements. It copies properties
Expand All @@ -41,28 +41,46 @@ var __copyProps = (to, from, except, desc) => {
// also copy the properties to "module.exports" in addition to our module's
// internal ESM export object.
var __reExport = (target, mod, secondTarget) => (
__copyProps(target, mod, 'default'),
secondTarget && __copyProps(secondTarget, mod, 'default')
__copyProps(target, mod, 'default'),
secondTarget && __copyProps(secondTarget, mod, 'default')
)

// Converts the module from CommonJS to ESM. When in node mode (i.e. in an
// ".mjs" file, package.json has "type: module", or the "__esModule" export
// in the CommonJS file is falsy or missing), the "default" property is
// overridden to point to the original CommonJS exports object instead.
var __toESM = (mod, isNodeMode, target) => (
target = mod != null ? __create(__getProtoOf(mod)) : {},
__copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule
? __defProp(target, 'default', { value: mod, enumerable: true })
: target,
mod)
target = mod != null ? __create(__getProtoOf(mod)) : {},
__copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule
? __defProp(target, 'default', { value: mod, enumerable: true })
: target,
mod)
)

// Converts the module from ESM to CommonJS. This clones the input module
// object with the addition of a non-enumerable "__esModule" property set
// to "true", which overwrites any existing export named "__esModule".
var __toCommonJS = mod => __copyProps(__defProp({}, '__esModule', { value: true }), mod)

// This is for the "binary" loader (custom code is ~2x faster than "atob")
export var __toBinaryNode = base64 => new Uint8Array(Buffer.from(base64, 'base64'))
export var __toBinary = /* @__PURE__ */ (() => {
var table = new Uint8Array(128)
for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i
return base64 => {
var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0)
for (var i = 0, j = 0; i < n;) {
var c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)]
var c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)]
bytes[j++] = (c0 << 2) | (c1 >> 4)
bytes[j++] = (c1 << 4) | (c2 >> 2)
bytes[j++] = (c2 << 6) | c3
}
return bytes
}
})()
2 changes: 2 additions & 0 deletions crates/rolldown/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ impl RuntimeModuleBrief {
(self.id, *symbol_id).into()
}
}

pub static ROLLDOWN_RUNTIME_RESOURCE_ID: &str = "rolldown:runtime";
16 changes: 16 additions & 0 deletions crates/rolldown/src/runtime/runtime-without-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ var __toESM = (mod, isNodeMode, target) => (
mod)
)
var __toCommonJS = mod => __copyProps(__defProp({}, '__esModule', { value: true }), mod)
export var __toBinaryNode = base64 => new Uint8Array(Buffer.from(base64, 'base64'))
export var __toBinary = /* @__PURE__ */ (() => {
var table = new Uint8Array(128)
for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i
return base64 => {
var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0)
for (var i = 0, j = 0; i < n;) {
var c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)]
var c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)]
bytes[j++] = (c0 << 2) | (c1 >> 4)
bytes[j++] = (c1 << 4) | (c2 >> 2)
bytes[j++] = (c2 << 6) | c3
}
return bytes
}
})()
2 changes: 1 addition & 1 deletion crates/rolldown/src/utils/load_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub async fn load_source(
String::new()
} else {
match module_type {
ModuleType::Base64 => {
ModuleType::Base64 | ModuleType::Binary => {
rolldown_utils::base64::to_standard_base64(fs.read(resolved_path.path.as_path())?)
}
_ => fs.read_to_string(resolved_path.path.as_path())?,
Expand Down
10 changes: 8 additions & 2 deletions crates/rolldown/src/utils/parse_to_ast.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::sync::Arc;

use oxc::span::SourceType as OxcSourceType;
use rolldown_common::ModuleType;
use rolldown_loader_utils::{base64_to_esm, json_to_esm, text_to_esm};
use rolldown_common::{ModuleType, NormalizedBundlerOptions};
use rolldown_loader_utils::{base64_to_esm, binary_to_esm, json_to_esm, text_to_esm};
use rolldown_oxc_utils::{OxcAst, OxcCompiler};

use crate::runtime::ROLLDOWN_RUNTIME_RESOURCE_ID;

fn pure_esm_js_oxc_source_type() -> OxcSourceType {
let pure_esm_js = OxcSourceType::default().with_module(true);
debug_assert!(pure_esm_js.is_javascript());
Expand All @@ -24,6 +26,7 @@ enum ParseType {
}

pub fn parse_to_ast(
options: &NormalizedBundlerOptions,
module_type: ModuleType,
source: impl Into<Arc<str>>,
) -> anyhow::Result<OxcAst> {
Expand All @@ -35,6 +38,9 @@ pub fn parse_to_ast(
ModuleType::Json => (json_to_esm(&source)?.into(), ParseType::Js),
ModuleType::Text => (text_to_esm(&source)?.into(), ParseType::Js),
ModuleType::Base64 => (base64_to_esm(&source).into(), ParseType::Js),
ModuleType::Binary => {
(binary_to_esm(&source, options.platform, ROLLDOWN_RUNTIME_RESOURCE_ID).into(), ParseType::Js)
}
};

// 2. Parse the source to AST and transform non-js AST to valid JS AST.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"config": {
"moduleTypes": {
".webp": "binary"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/fixtures/loaders/binary/binary
---
# Assets

## main.mjs

```js
//#region rolldown.webp
var rolldown_default = __toBinary('UklGRgoKAABXRUJQVlA4WAoAAAAQAAAAXwAAXwAAQUxQSIACAAABkCNt/5tGP42DZjSqVEmjFs4htY6lnCqoUsNNuEA6gAMVJ9iIKyqcGMeOWIY/3v9vAyDp//9m64iYAFLTcMJytdV5niwkzycvt61qKXAMQume1+6WnODyrnbhAvArXwWnuPha8bXaOm4LTl20j7Z0sUp9VrRfsHQwix+s8HvBVG6vx4r39tTyLn+x8vLSU8c4G7GWo1NDEbshWVPZtJXIdFnjblaBYMBaD8PUohlrPo9SygnWXuRTyX8ywM9cCpFgiCJKLJwxyHmQUHbIMIeZROwuA+3aCRhNhto04p1KLPIsljdisCMvziXDvYyxJ/HIvY3MHgPumZsUGHJxA+sd04e1rsCgS2u2+qj6W6uOOF2pjozHx6vaKWndXuELXML/p8LAK/98QfaViNwFMuESXTD0c6IathoZd9juDGeJbekEDD4soStX0VVb6Fq36Dov6J6n6CZzdHP+71+gm0/QTV7WSFQvnTWwOy10rSq6ahldKUQXOEtsS8e4w3ZnUA1bnegc2wWRK5AtXCL6iuwrEVEFWeUfX+Ba+P9QG1ebVh7jOlq11UfV31pFJVQFWmt9YHq31lExFamOjFWgDc1eGvr2zE1oT+KRe7T5JZ5LiumN0Iy9OHQmschTim00sTSNeGR3kXRtSjIzxDHMUrLBDMUspKQjgUFElHzuE8FnntLMC/1EjtKNZrrNIko7HOo1DCj9bFenboZUtJtSF9m0SU3jdKTH6MwgZb1LqZ689EjpvZ5qvT1S3Sy8q/RRNElDq9BXpV+ySNOto7ZIQMYR7eMt0tmvfF3E2Vx8rfikv3tRu1smsbyrnbuE0nCCUrV1+zKdM88nL51WtRw6BqkJVlA4IGQHAAAwIgCdASpgAGAAPm0skUWkIqGYCx6oQAbEtgBa6tvsjx4+8/kz7Itbfs34U5d+ZvNx5d/6fSA8wD9OelP5gP2P/cj3wPSB6AH8y/5/WE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6M8NOpboCUg0xhYa7vBdl5VguSL4nHoDYDiztuQGrx4OgYPAtRFiVfWhdOCWLSXZ4ljQGi+KW3rG5V0X01dYZz6evIXP9wqHhkekw2K4y842vn82Rb6t+Pi6pgups0s1uNfLhui1LRbW34my38Go3JeuNaxQAfyW+4LPx9LvOHRxLR8XmMi3TGw1pSsP0Je64S2R4lD6XxOa/ujg+hf3Z3//R///o4r//ovn/9unf+Ebnn8cZgMBAwsVra6s78StHcigPdOIHNGzgAAAA==');
//#endregion
//#region main.js
console.log(rolldown_default);
//#endregion
```
3 changes: 3 additions & 0 deletions crates/rolldown/tests/fixtures/loaders/binary/binary/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import value from './rolldown.webp';

console.log(value);
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"config": {
"moduleTypes": {
".data": "binary"
}
}
}
21 changes: 21 additions & 0 deletions crates/rolldown/tests/fixtures/loaders/binary/empty/artifacts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/fixtures/loaders/binary/empty
---
# Assets

## main.mjs

```js
//#region example.data
var example_default = __toBinary('');
//#endregion
//#region main.js
console.log(example_default);
//#endregion
```
Empty file.
3 changes: 3 additions & 0 deletions crates/rolldown/tests/fixtures/loaders/binary/empty/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import value from './example.data'

console.log(value);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"config": {
"moduleTypes": {
".data": "binary"
},
"platform": "node"
}
}
6 changes: 6 additions & 0 deletions crates/rolldown/tests/fixtures/loaders/binary/node/_test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import buffer from './dist/main.mjs';
import assert from 'node:assert';
import fs from 'node:fs/promises';
import path from 'node:path';

assert((await fs.readFile(path.resolve(import.meta.dirname, 'text.data'))).equals(buffer));
23 changes: 23 additions & 0 deletions crates/rolldown/tests/fixtures/loaders/binary/node/artifacts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/fixtures/loaders/binary/node
---
# Assets

## main.mjs

```js
//#region text.data
var text_default = __toBinaryNode('IidgKz0vQCMkJCVeJiooCuS9oOWlve+8jOS4lueVjArQn9GA0LjQstC10YIg0LzQuNGACuOBk+OCk+OBq+OBoeOBr+S4lueVjAo=');
//#endregion
//#region main.js
console.log(text_default);
var main_default = text_default;
//#endregion
export { main_default as default };
```
5 changes: 5 additions & 0 deletions crates/rolldown/tests/fixtures/loaders/binary/node/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import value from './text.data'

console.log(value);

export default value;
Loading

0 comments on commit 8f2e07b

Please sign in to comment.