File size: 1,199 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
use serde::Serialize;
use turbo_tasks::ReadRef;
use turbopack_core::chunk::{ChunkData, ModuleId};
#[derive(Serialize, Hash, PartialEq, Eq)]
#[serde(untagged)]
pub enum EcmascriptChunkData<'a> {
Simple(&'a str),
#[serde(rename_all = "camelCase")]
WithRuntimeInfo {
path: &'a str,
#[serde(skip_serializing_if = "<[_]>::is_empty", default)]
included: &'a [ReadRef<ModuleId>],
#[serde(skip_serializing_if = "<[_]>::is_empty", default)]
excluded: &'a [ReadRef<ModuleId>],
#[serde(skip_serializing_if = "<[_]>::is_empty", default)]
module_chunks: &'a [String],
},
}
impl EcmascriptChunkData<'_> {
pub fn new(chunk_data: &ChunkData) -> EcmascriptChunkData<'_> {
let ChunkData {
path,
included,
excluded,
module_chunks,
references: _,
} = chunk_data;
if included.is_empty() && excluded.is_empty() && module_chunks.is_empty() {
return EcmascriptChunkData::Simple(path);
}
EcmascriptChunkData::WithRuntimeInfo {
path,
included,
excluded,
module_chunks,
}
}
}
|