2024-01-01 19:58:21 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2021-10-10 21:26:22 +00:00
|
|
|
|
2022-07-12 22:58:39 +00:00
|
|
|
use crate::cache::EmitCache;
|
2022-07-19 15:58:18 +00:00
|
|
|
use crate::cache::FastInsecureHasher;
|
2022-08-22 16:14:59 +00:00
|
|
|
use crate::cache::ParsedSourceCache;
|
2024-11-01 16:27:00 +00:00
|
|
|
use crate::resolver::CjsTracker;
|
2021-10-10 21:26:22 +00:00
|
|
|
|
2024-11-01 16:27:00 +00:00
|
|
|
use deno_ast::ModuleKind;
|
2024-04-11 23:00:17 +00:00
|
|
|
use deno_ast::SourceMapOption;
|
2024-08-21 17:12:56 +00:00
|
|
|
use deno_ast::SourceRange;
|
|
|
|
use deno_ast::SourceRanged;
|
|
|
|
use deno_ast::SourceRangedForSpanned;
|
2024-11-01 16:27:00 +00:00
|
|
|
use deno_ast::TranspileModuleOptions;
|
2024-04-17 19:15:02 +00:00
|
|
|
use deno_ast::TranspileResult;
|
2021-10-10 21:26:22 +00:00
|
|
|
use deno_core::error::AnyError;
|
2024-05-20 17:49:12 +00:00
|
|
|
use deno_core::futures::stream::FuturesUnordered;
|
|
|
|
use deno_core::futures::FutureExt;
|
|
|
|
use deno_core::futures::StreamExt;
|
2021-10-10 21:26:22 +00:00
|
|
|
use deno_core::ModuleSpecifier;
|
|
|
|
use deno_graph::MediaType;
|
2023-04-13 18:03:07 +00:00
|
|
|
use deno_graph::Module;
|
|
|
|
use deno_graph::ModuleGraph;
|
2021-10-10 21:26:22 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2024-11-01 16:27:00 +00:00
|
|
|
#[derive(Debug)]
|
2023-04-13 18:03:07 +00:00
|
|
|
pub struct Emitter {
|
2024-11-01 16:27:00 +00:00
|
|
|
cjs_tracker: Arc<CjsTracker>,
|
2024-08-08 09:41:30 +00:00
|
|
|
emit_cache: Arc<EmitCache>,
|
2023-04-14 20:22:33 +00:00
|
|
|
parsed_source_cache: Arc<ParsedSourceCache>,
|
2024-05-18 15:42:03 +00:00
|
|
|
transpile_and_emit_options:
|
|
|
|
Arc<(deno_ast::TranspileOptions, deno_ast::EmitOptions)>,
|
2024-04-11 23:00:17 +00:00
|
|
|
// cached hash of the transpile and emit options
|
|
|
|
transpile_and_emit_options_hash: u64,
|
2021-10-10 21:26:22 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 18:03:07 +00:00
|
|
|
impl Emitter {
|
|
|
|
pub fn new(
|
2024-11-01 16:27:00 +00:00
|
|
|
cjs_tracker: Arc<CjsTracker>,
|
2024-08-08 09:41:30 +00:00
|
|
|
emit_cache: Arc<EmitCache>,
|
2023-04-14 20:22:33 +00:00
|
|
|
parsed_source_cache: Arc<ParsedSourceCache>,
|
2024-04-11 23:00:17 +00:00
|
|
|
transpile_options: deno_ast::TranspileOptions,
|
2023-04-13 18:03:07 +00:00
|
|
|
emit_options: deno_ast::EmitOptions,
|
|
|
|
) -> Self {
|
2024-04-11 23:00:17 +00:00
|
|
|
let transpile_and_emit_options_hash = {
|
2024-05-29 18:38:18 +00:00
|
|
|
let mut hasher = FastInsecureHasher::new_without_deno_version();
|
2024-04-11 23:00:17 +00:00
|
|
|
hasher.write_hashable(&transpile_options);
|
2024-04-17 19:15:02 +00:00
|
|
|
hasher.write_hashable(&emit_options);
|
2024-04-11 23:00:17 +00:00
|
|
|
hasher.finish()
|
|
|
|
};
|
2023-04-13 18:03:07 +00:00
|
|
|
Self {
|
2024-11-01 16:27:00 +00:00
|
|
|
cjs_tracker,
|
2023-04-13 18:03:07 +00:00
|
|
|
emit_cache,
|
|
|
|
parsed_source_cache,
|
2024-05-18 15:42:03 +00:00
|
|
|
transpile_and_emit_options: Arc::new((transpile_options, emit_options)),
|
2024-04-11 23:00:17 +00:00
|
|
|
transpile_and_emit_options_hash,
|
2023-04-13 18:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-18 15:42:03 +00:00
|
|
|
pub async fn cache_module_emits(
|
2023-04-13 18:03:07 +00:00
|
|
|
&self,
|
|
|
|
graph: &ModuleGraph,
|
|
|
|
) -> Result<(), AnyError> {
|
2024-05-20 17:49:12 +00:00
|
|
|
let mut futures = FuturesUnordered::new();
|
2023-04-13 18:03:07 +00:00
|
|
|
for module in graph.modules() {
|
2024-05-20 17:49:12 +00:00
|
|
|
let Module::Js(module) = module else {
|
|
|
|
continue;
|
|
|
|
};
|
|
|
|
|
2024-11-01 16:27:00 +00:00
|
|
|
if module.media_type.is_emittable() {
|
2024-05-20 17:49:12 +00:00
|
|
|
futures.push(
|
2024-05-18 15:42:03 +00:00
|
|
|
self
|
|
|
|
.emit_parsed_source(
|
|
|
|
&module.specifier,
|
|
|
|
module.media_type,
|
2024-11-01 16:27:00 +00:00
|
|
|
ModuleKind::from_is_cjs(
|
|
|
|
self.cjs_tracker.is_cjs_with_known_is_script(
|
|
|
|
&module.specifier,
|
|
|
|
module.media_type,
|
|
|
|
module.is_script,
|
|
|
|
)?,
|
|
|
|
),
|
2024-05-18 15:42:03 +00:00
|
|
|
&module.source,
|
|
|
|
)
|
2024-05-20 17:49:12 +00:00
|
|
|
.boxed_local(),
|
|
|
|
);
|
2023-04-13 18:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-20 17:49:12 +00:00
|
|
|
|
|
|
|
while let Some(result) = futures.next().await {
|
|
|
|
result?; // surface errors
|
|
|
|
}
|
|
|
|
|
2023-04-13 18:03:07 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-04-14 20:22:33 +00:00
|
|
|
/// Gets a cached emit if the source matches the hash found in the cache.
|
2023-06-26 13:10:27 +00:00
|
|
|
pub fn maybe_cached_emit(
|
2023-04-14 20:22:33 +00:00
|
|
|
&self,
|
|
|
|
specifier: &ModuleSpecifier,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind: deno_ast::ModuleKind,
|
2023-04-14 20:22:33 +00:00
|
|
|
source: &str,
|
2024-10-26 17:41:09 +00:00
|
|
|
) -> Option<String> {
|
2024-11-01 16:27:00 +00:00
|
|
|
let source_hash = self.get_source_hash(module_kind, source);
|
2023-04-14 20:22:33 +00:00
|
|
|
self.emit_cache.get_emit_code(specifier, source_hash)
|
|
|
|
}
|
|
|
|
|
2024-05-18 15:42:03 +00:00
|
|
|
pub async fn emit_parsed_source(
|
2023-04-13 18:03:07 +00:00
|
|
|
&self,
|
|
|
|
specifier: &ModuleSpecifier,
|
|
|
|
media_type: MediaType,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind: deno_ast::ModuleKind,
|
2023-04-13 18:03:07 +00:00
|
|
|
source: &Arc<str>,
|
2024-10-26 17:41:09 +00:00
|
|
|
) -> Result<String, AnyError> {
|
2024-05-18 15:42:03 +00:00
|
|
|
// Note: keep this in sync with the sync version below
|
|
|
|
let helper = EmitParsedSourceHelper(self);
|
2024-11-01 16:27:00 +00:00
|
|
|
match helper.pre_emit_parsed_source(specifier, module_kind, source) {
|
2024-05-18 15:42:03 +00:00
|
|
|
PreEmitResult::Cached(emitted_text) => Ok(emitted_text),
|
|
|
|
PreEmitResult::NotCached { source_hash } => {
|
|
|
|
let parsed_source_cache = self.parsed_source_cache.clone();
|
|
|
|
let transpile_and_emit_options =
|
|
|
|
self.transpile_and_emit_options.clone();
|
2024-10-26 17:41:09 +00:00
|
|
|
let transpiled_source = deno_core::unsync::spawn_blocking({
|
2024-08-29 01:06:09 +00:00
|
|
|
let specifier = specifier.clone();
|
|
|
|
let source = source.clone();
|
|
|
|
move || -> Result<_, AnyError> {
|
|
|
|
EmitParsedSourceHelper::transpile(
|
|
|
|
&parsed_source_cache,
|
|
|
|
&specifier,
|
|
|
|
media_type,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind,
|
|
|
|
source.clone(),
|
2024-08-29 01:06:09 +00:00
|
|
|
&transpile_and_emit_options.0,
|
|
|
|
&transpile_and_emit_options.1,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.await
|
|
|
|
.unwrap()?;
|
2024-10-26 17:41:09 +00:00
|
|
|
helper.post_emit_parsed_source(
|
2024-05-18 15:42:03 +00:00
|
|
|
specifier,
|
2024-10-26 17:41:09 +00:00
|
|
|
&transpiled_source,
|
2024-05-18 15:42:03 +00:00
|
|
|
source_hash,
|
2024-10-26 17:41:09 +00:00
|
|
|
);
|
|
|
|
Ok(transpiled_source)
|
2024-05-18 15:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-13 18:03:07 +00:00
|
|
|
|
2024-05-18 15:42:03 +00:00
|
|
|
pub fn emit_parsed_source_sync(
|
|
|
|
&self,
|
|
|
|
specifier: &ModuleSpecifier,
|
|
|
|
media_type: MediaType,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind: deno_ast::ModuleKind,
|
2024-05-18 15:42:03 +00:00
|
|
|
source: &Arc<str>,
|
2024-10-26 17:41:09 +00:00
|
|
|
) -> Result<String, AnyError> {
|
2024-05-18 15:42:03 +00:00
|
|
|
// Note: keep this in sync with the async version above
|
|
|
|
let helper = EmitParsedSourceHelper(self);
|
2024-11-01 16:27:00 +00:00
|
|
|
match helper.pre_emit_parsed_source(specifier, module_kind, source) {
|
2024-05-18 15:42:03 +00:00
|
|
|
PreEmitResult::Cached(emitted_text) => Ok(emitted_text),
|
|
|
|
PreEmitResult::NotCached { source_hash } => {
|
2024-10-26 17:41:09 +00:00
|
|
|
let transpiled_source = EmitParsedSourceHelper::transpile(
|
2024-08-29 01:06:09 +00:00
|
|
|
&self.parsed_source_cache,
|
|
|
|
specifier,
|
|
|
|
media_type,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind,
|
|
|
|
source.clone(),
|
2024-08-29 01:06:09 +00:00
|
|
|
&self.transpile_and_emit_options.0,
|
|
|
|
&self.transpile_and_emit_options.1,
|
|
|
|
)?;
|
2024-10-26 17:41:09 +00:00
|
|
|
helper.post_emit_parsed_source(
|
2024-05-18 15:42:03 +00:00
|
|
|
specifier,
|
2024-10-26 17:41:09 +00:00
|
|
|
&transpiled_source,
|
2024-05-18 15:42:03 +00:00
|
|
|
source_hash,
|
2024-10-26 17:41:09 +00:00
|
|
|
);
|
|
|
|
Ok(transpiled_source)
|
2024-05-18 15:42:03 +00:00
|
|
|
}
|
2023-04-13 18:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-31 00:25:58 +00:00
|
|
|
/// Expects a file URL, panics otherwise.
|
|
|
|
pub async fn load_and_emit_for_hmr(
|
|
|
|
&self,
|
|
|
|
specifier: &ModuleSpecifier,
|
|
|
|
) -> Result<String, AnyError> {
|
|
|
|
let media_type = MediaType::from_specifier(specifier);
|
|
|
|
let source_code = tokio::fs::read_to_string(
|
|
|
|
ModuleSpecifier::to_file_path(specifier).unwrap(),
|
|
|
|
)
|
|
|
|
.await?;
|
2024-06-05 15:04:16 +00:00
|
|
|
match media_type {
|
|
|
|
MediaType::TypeScript
|
|
|
|
| MediaType::Mts
|
|
|
|
| MediaType::Cts
|
|
|
|
| MediaType::Jsx
|
|
|
|
| MediaType::Tsx => {
|
|
|
|
let source_arc: Arc<str> = source_code.into();
|
|
|
|
let parsed_source = self
|
|
|
|
.parsed_source_cache
|
|
|
|
.remove_or_parse_module(specifier, source_arc, media_type)?;
|
|
|
|
// HMR doesn't work with embedded source maps for some reason, so set
|
|
|
|
// the option to not use them (though you should test this out because
|
|
|
|
// this statement is probably wrong)
|
|
|
|
let mut options = self.transpile_and_emit_options.1.clone();
|
|
|
|
options.source_map = SourceMapOption::None;
|
2024-11-13 15:10:09 +00:00
|
|
|
let is_cjs = self.cjs_tracker.is_cjs_with_known_is_script(
|
|
|
|
specifier,
|
|
|
|
media_type,
|
|
|
|
parsed_source.compute_is_script(),
|
|
|
|
)?;
|
2024-06-05 15:04:16 +00:00
|
|
|
let transpiled_source = parsed_source
|
2024-11-01 16:27:00 +00:00
|
|
|
.transpile(
|
|
|
|
&self.transpile_and_emit_options.0,
|
|
|
|
&deno_ast::TranspileModuleOptions {
|
2024-11-13 15:10:09 +00:00
|
|
|
module_kind: Some(ModuleKind::from_is_cjs(is_cjs)),
|
2024-11-01 16:27:00 +00:00
|
|
|
},
|
|
|
|
&options,
|
|
|
|
)?
|
|
|
|
.into_source();
|
2024-06-05 15:04:16 +00:00
|
|
|
Ok(transpiled_source.text)
|
|
|
|
}
|
|
|
|
MediaType::JavaScript
|
|
|
|
| MediaType::Mjs
|
|
|
|
| MediaType::Cjs
|
|
|
|
| MediaType::Dts
|
|
|
|
| MediaType::Dmts
|
|
|
|
| MediaType::Dcts
|
|
|
|
| MediaType::Json
|
|
|
|
| MediaType::Wasm
|
2024-11-01 16:27:00 +00:00
|
|
|
| MediaType::Css
|
2024-06-05 15:04:16 +00:00
|
|
|
| MediaType::SourceMap
|
|
|
|
| MediaType::Unknown => {
|
|
|
|
// clear this specifier from the parsed source cache as it's now out of date
|
|
|
|
self.parsed_source_cache.free(specifier);
|
|
|
|
Ok(source_code)
|
|
|
|
}
|
|
|
|
}
|
2023-10-31 00:25:58 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 18:03:07 +00:00
|
|
|
/// A hashing function that takes the source code and uses the global emit
|
|
|
|
/// options then generates a string hash which can be stored to
|
|
|
|
/// determine if the cached emit is valid or not.
|
2024-11-01 16:27:00 +00:00
|
|
|
fn get_source_hash(&self, module_kind: ModuleKind, source_text: &str) -> u64 {
|
2024-05-29 18:38:18 +00:00
|
|
|
FastInsecureHasher::new_without_deno_version() // stored in the transpile_and_emit_options_hash
|
2023-04-13 18:03:07 +00:00
|
|
|
.write_str(source_text)
|
2024-04-11 23:00:17 +00:00
|
|
|
.write_u64(self.transpile_and_emit_options_hash)
|
2024-11-01 16:27:00 +00:00
|
|
|
.write_hashable(module_kind)
|
2023-04-13 18:03:07 +00:00
|
|
|
.finish()
|
2021-10-10 21:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-18 15:42:03 +00:00
|
|
|
|
|
|
|
enum PreEmitResult {
|
2024-10-26 17:41:09 +00:00
|
|
|
Cached(String),
|
2024-05-18 15:42:03 +00:00
|
|
|
NotCached { source_hash: u64 },
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Helper to share code between async and sync emit_parsed_source methods.
|
|
|
|
struct EmitParsedSourceHelper<'a>(&'a Emitter);
|
|
|
|
|
|
|
|
impl<'a> EmitParsedSourceHelper<'a> {
|
|
|
|
pub fn pre_emit_parsed_source(
|
|
|
|
&self,
|
|
|
|
specifier: &ModuleSpecifier,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind: deno_ast::ModuleKind,
|
2024-05-18 15:42:03 +00:00
|
|
|
source: &Arc<str>,
|
|
|
|
) -> PreEmitResult {
|
2024-11-01 16:27:00 +00:00
|
|
|
let source_hash = self.0.get_source_hash(module_kind, source);
|
2024-05-18 15:42:03 +00:00
|
|
|
|
|
|
|
if let Some(emit_code) =
|
|
|
|
self.0.emit_cache.get_emit_code(specifier, source_hash)
|
|
|
|
{
|
2024-10-26 17:41:09 +00:00
|
|
|
PreEmitResult::Cached(emit_code)
|
2024-05-18 15:42:03 +00:00
|
|
|
} else {
|
|
|
|
PreEmitResult::NotCached { source_hash }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn transpile(
|
|
|
|
parsed_source_cache: &ParsedSourceCache,
|
|
|
|
specifier: &ModuleSpecifier,
|
|
|
|
media_type: MediaType,
|
2024-11-01 16:27:00 +00:00
|
|
|
module_kind: deno_ast::ModuleKind,
|
|
|
|
source: Arc<str>,
|
2024-05-18 15:42:03 +00:00
|
|
|
transpile_options: &deno_ast::TranspileOptions,
|
|
|
|
emit_options: &deno_ast::EmitOptions,
|
2024-10-26 17:41:09 +00:00
|
|
|
) -> Result<String, AnyError> {
|
2024-05-18 15:42:03 +00:00
|
|
|
// nothing else needs the parsed source at this point, so remove from
|
|
|
|
// the cache in order to not transpile owned
|
|
|
|
let parsed_source = parsed_source_cache
|
|
|
|
.remove_or_parse_module(specifier, source, media_type)?;
|
2024-08-29 01:06:09 +00:00
|
|
|
ensure_no_import_assertion(&parsed_source)?;
|
2024-11-01 16:27:00 +00:00
|
|
|
let transpile_result = parsed_source.transpile(
|
|
|
|
transpile_options,
|
|
|
|
&TranspileModuleOptions {
|
|
|
|
module_kind: Some(module_kind),
|
|
|
|
},
|
|
|
|
emit_options,
|
|
|
|
)?;
|
2024-05-18 15:42:03 +00:00
|
|
|
let transpiled_source = match transpile_result {
|
|
|
|
TranspileResult::Owned(source) => source,
|
|
|
|
TranspileResult::Cloned(source) => {
|
|
|
|
debug_assert!(false, "Transpile owned failed.");
|
|
|
|
source
|
|
|
|
}
|
|
|
|
};
|
|
|
|
debug_assert!(transpiled_source.source_map.is_none());
|
2024-11-01 16:27:00 +00:00
|
|
|
Ok(transpiled_source.text)
|
2024-10-26 17:41:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn post_emit_parsed_source(
|
|
|
|
&self,
|
|
|
|
specifier: &ModuleSpecifier,
|
|
|
|
transpiled_source: &str,
|
|
|
|
source_hash: u64,
|
|
|
|
) {
|
2024-08-29 01:06:09 +00:00
|
|
|
self.0.emit_cache.set_emit_code(
|
|
|
|
specifier,
|
|
|
|
source_hash,
|
2024-10-26 17:41:09 +00:00
|
|
|
transpiled_source.as_bytes(),
|
2024-08-29 01:06:09 +00:00
|
|
|
);
|
2024-05-18 15:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-21 17:12:56 +00:00
|
|
|
|
2024-08-29 01:06:09 +00:00
|
|
|
// todo(dsherret): this is a temporary measure until we have swc erroring for this
|
|
|
|
fn ensure_no_import_assertion(
|
|
|
|
parsed_source: &deno_ast::ParsedSource,
|
|
|
|
) -> Result<(), AnyError> {
|
2024-08-21 17:12:56 +00:00
|
|
|
fn has_import_assertion(text: &str) -> bool {
|
|
|
|
// good enough
|
|
|
|
text.contains(" assert ") && !text.contains(" with ")
|
|
|
|
}
|
|
|
|
|
2024-08-29 01:06:09 +00:00
|
|
|
fn create_err(
|
2024-08-21 17:12:56 +00:00
|
|
|
parsed_source: &deno_ast::ParsedSource,
|
|
|
|
range: SourceRange,
|
2024-08-29 01:06:09 +00:00
|
|
|
) -> AnyError {
|
2024-08-21 17:12:56 +00:00
|
|
|
let text_info = parsed_source.text_info_lazy();
|
|
|
|
let loc = text_info.line_and_column_display(range.start);
|
2024-08-29 01:06:09 +00:00
|
|
|
let mut msg = "Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword.".to_string();
|
|
|
|
msg.push_str("\n\n");
|
|
|
|
msg.push_str(range.text_fast(text_info));
|
|
|
|
msg.push_str("\n\n");
|
|
|
|
msg.push_str(&format!(
|
|
|
|
" at {}:{}:{}\n",
|
|
|
|
parsed_source.specifier(),
|
|
|
|
loc.line_number,
|
|
|
|
loc.column_number,
|
|
|
|
));
|
|
|
|
deno_core::anyhow::anyhow!("{}", msg)
|
2024-08-21 17:12:56 +00:00
|
|
|
}
|
|
|
|
|
2024-11-01 16:27:00 +00:00
|
|
|
let deno_ast::ProgramRef::Module(module) = parsed_source.program_ref() else {
|
2024-08-29 01:06:09 +00:00
|
|
|
return Ok(());
|
2024-08-21 17:12:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for item in &module.body {
|
|
|
|
match item {
|
|
|
|
deno_ast::swc::ast::ModuleItem::ModuleDecl(decl) => match decl {
|
|
|
|
deno_ast::swc::ast::ModuleDecl::Import(n) => {
|
|
|
|
if n.with.is_some()
|
|
|
|
&& has_import_assertion(n.text_fast(parsed_source.text_info_lazy()))
|
|
|
|
{
|
2024-08-29 01:06:09 +00:00
|
|
|
return Err(create_err(parsed_source, n.range()));
|
2024-08-21 17:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
deno_ast::swc::ast::ModuleDecl::ExportAll(n) => {
|
|
|
|
if n.with.is_some()
|
|
|
|
&& has_import_assertion(n.text_fast(parsed_source.text_info_lazy()))
|
|
|
|
{
|
2024-08-29 01:06:09 +00:00
|
|
|
return Err(create_err(parsed_source, n.range()));
|
2024-08-21 17:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
deno_ast::swc::ast::ModuleDecl::ExportNamed(n) => {
|
|
|
|
if n.with.is_some()
|
|
|
|
&& has_import_assertion(n.text_fast(parsed_source.text_info_lazy()))
|
|
|
|
{
|
2024-08-29 01:06:09 +00:00
|
|
|
return Err(create_err(parsed_source, n.range()));
|
2024-08-21 17:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
deno_ast::swc::ast::ModuleDecl::ExportDecl(_)
|
|
|
|
| deno_ast::swc::ast::ModuleDecl::ExportDefaultDecl(_)
|
|
|
|
| deno_ast::swc::ast::ModuleDecl::ExportDefaultExpr(_)
|
|
|
|
| deno_ast::swc::ast::ModuleDecl::TsImportEquals(_)
|
|
|
|
| deno_ast::swc::ast::ModuleDecl::TsExportAssignment(_)
|
|
|
|
| deno_ast::swc::ast::ModuleDecl::TsNamespaceExport(_) => {}
|
|
|
|
},
|
|
|
|
deno_ast::swc::ast::ModuleItem::Stmt(_) => {}
|
|
|
|
}
|
|
|
|
}
|
2024-08-29 01:06:09 +00:00
|
|
|
|
|
|
|
Ok(())
|
2024-08-21 17:12:56 +00:00
|
|
|
}
|