Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/qwik-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@emotion/react": "^11.9.0",
"@emotion/server": "^11.4.0",
"@emotion/styled": "^11.9.3",
"@mui/material": "5.1.1",
"@types/react": "^18.0.1",
"@types/react-dom": "^18.0.0",
"react": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/src/react/client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jsxImportSource react */
/** @jsxImportSource @emotion/react */
import { CacheProvider } from '@emotion/react';
import createCache from '@emotion/cache';

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/src/react/server.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jsxImportSource react */
/** @jsxImportSource @emotion/react */

import { CacheProvider } from '@emotion/react';
import { renderToString } from 'react-dom/server';
Expand Down
6 changes: 3 additions & 3 deletions packages/qwik/src/optimizer/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct OptimizerInput {
transpile: bool,
minify: MinifyMode,
sourcemaps: bool,
explicity_extensions: bool,
explicit_extensions: bool,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -99,7 +99,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
glob: None,
strategy,
minify,
explicity_extensions: matches.is_present("extensions"),
explicit_extensions: matches.is_present("extensions"),
transpile: !matches.is_present("no-transpile"),
sourcemaps: matches.is_present("sourcemaps"),
})?;
Expand All @@ -121,7 +121,7 @@ fn optimize(
minify: optimizer_input.minify,
transpile: optimizer_input.transpile,
entry_strategy: optimizer_input.strategy,
explicity_extensions: optimizer_input.explicity_extensions,
explicit_extensions: optimizer_input.explicit_extensions,
dev: true,
scope: None,
})?;
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/optimizer/core/benches/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn transform_todo_app(b: &mut Bencher) {
path: "file.tsx".into(),
}],
source_maps: false,
explicity_extensions: false,
explicit_extensions: false,
minify: MinifyMode::Simplify,
transpile: true,
entry_strategy: EntryStrategy::Single,
Expand Down
8 changes: 4 additions & 4 deletions packages/qwik/src/optimizer/core/src/code_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ fn test_fix_path() {

pub fn generate_entries(
mut output: TransformOutput,
explicity_extensions: bool,
explicit_extensions: bool,
) -> Result<TransformOutput, anyhow::Error> {
let source_map = Lrc::new(SourceMap::default());
let mut entries_map: BTreeMap<&str, Vec<&HookAnalysis>> = BTreeMap::new();
Expand All @@ -240,7 +240,7 @@ pub fn generate_entries(
}

for (entry, hooks) in &entries_map {
let module = new_entry_module(hooks, explicity_extensions);
let module = new_entry_module(hooks, explicit_extensions);
let (code, map) = emit_source_code(Lrc::clone(&source_map), None, &module, false)
.context("Emitting source code")?;
new_modules.push(TransformModule {
Expand All @@ -258,7 +258,7 @@ pub fn generate_entries(
Ok(output)
}

fn new_entry_module(hooks: &[&HookAnalysis], explicity_extensions: bool) -> ast::Module {
fn new_entry_module(hooks: &[&HookAnalysis], explicit_extensions: bool) -> ast::Module {
let mut module = ast::Module {
span: DUMMY_SP,
body: Vec::with_capacity(hooks.len()),
Expand All @@ -267,7 +267,7 @@ fn new_entry_module(hooks: &[&HookAnalysis], explicity_extensions: bool) -> ast:
let mut need_handle_watch = false;
for hook in hooks {
let mut src = ["./", &hook.canonical_filename].concat();
if explicity_extensions {
if explicit_extensions {
src = src + "." + hook.extension.as_ref();
}
if might_need_handle_watch(&hook.ctx_kind, &hook.ctx_name) {
Expand Down
23 changes: 16 additions & 7 deletions packages/qwik/src/optimizer/core/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ impl GlobalCollect {
);
self.imports.insert(local, import);
}

pub fn add_export(&mut self, local: Id, exported: Option<JsWord>) -> bool {
if let std::collections::hash_map::Entry::Vacant(e) = self.exports.entry(local) {
e.insert(exported);
true
} else {
false
}
}
}

impl Visit for GlobalCollect {
Expand Down Expand Up @@ -189,7 +198,7 @@ impl Visit for GlobalCollect {
_ => None,
};
if let Some(local) = local {
self.exports.entry(local).or_insert(exported);
self.add_export(local, exported);
}
}
ast::ExportSpecifier::Default(default) => {
Expand All @@ -211,10 +220,10 @@ impl Visit for GlobalCollect {
fn visit_export_decl(&mut self, node: &ast::ExportDecl) {
match &node.decl {
ast::Decl::Class(class) => {
self.exports.insert(id!(class.ident), None);
self.add_export(id!(class.ident), None);
}
ast::Decl::Fn(func) => {
self.exports.insert(id!(func.ident), None);
self.add_export(id!(func.ident), None);
}
ast::Decl::Var(var) => {
for decl in &var.decls {
Expand All @@ -233,12 +242,12 @@ impl Visit for GlobalCollect {
match &node.decl {
ast::DefaultDecl::Class(class) => {
if let Some(ident) = &class.ident {
self.exports.insert(id!(ident), Some(js_word!("default")));
self.add_export(id!(ident), Some(js_word!("default")));
}
}
ast::DefaultDecl::Fn(func) => {
if let Some(ident) = &func.ident {
self.exports.insert(id!(ident), Some(js_word!("default")));
self.add_export(id!(ident), Some(js_word!("default")));
}
}
_ => {
Expand All @@ -249,13 +258,13 @@ impl Visit for GlobalCollect {

fn visit_binding_ident(&mut self, node: &ast::BindingIdent) {
if self.in_export_decl {
self.exports.insert(id!(node.id), None);
self.add_export(id!(node.id), None);
}
}

fn visit_assign_pat_prop(&mut self, node: &ast::AssignPatProp) {
if self.in_export_decl {
self.exports.insert(id!(node.key), None);
self.add_export(id!(node.key), None);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/qwik/src/optimizer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct TransformFsOptions {
pub entry_strategy: EntryStrategy,
pub source_maps: bool,
pub transpile: bool,
pub explicity_extensions: bool,
pub explicit_extensions: bool,
pub dev: bool,
pub scope: Option<String>,
}
Expand All @@ -69,7 +69,7 @@ pub struct TransformModulesOptions {
pub minify: MinifyMode,
pub transpile: bool,
pub entry_strategy: EntryStrategy,
pub explicity_extensions: bool,
pub explicit_extensions: bool,
pub dev: bool,
pub scope: Option<String>,
}
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn transform_fs(config: TransformFsOptions) -> Result<TransformOutput, Error
relative_path: relative_path.to_str().unwrap(),
minify: config.minify,
code: &code,
explicity_extensions: config.explicity_extensions,
explicit_extensions: config.explicit_extensions,
source_maps: config.source_maps,
transpile: config.transpile,
scope: config.scope.as_ref(),
Expand All @@ -110,7 +110,7 @@ pub fn transform_fs(config: TransformFsOptions) -> Result<TransformOutput, Error
.reduce(|| Ok(TransformOutput::new()), |x, y| Ok(x?.append(&mut y?)))?;

final_output.modules.sort_unstable_by_key(|key| key.order);
final_output = generate_entries(final_output, config.explicity_extensions)?;
final_output = generate_entries(final_output, config.explicit_extensions)?;
Ok(final_output)
}

Expand All @@ -131,7 +131,7 @@ pub fn transform_modules(config: TransformModulesOptions) -> Result<TransformOut
minify: config.minify,
source_maps: config.source_maps,
transpile: config.transpile,
explicity_extensions: config.explicity_extensions,
explicit_extensions: config.explicit_extensions,
entry_policy,
dev: config.dev,
scope: config.scope.as_ref(),
Expand All @@ -149,7 +149,7 @@ pub fn transform_modules(config: TransformModulesOptions) -> Result<TransformOut

let mut final_output = final_output?;
final_output.modules.sort_unstable_by_key(|key| key.order);
final_output = generate_entries(final_output, config.explicity_extensions)?;
final_output = generate_entries(final_output, config.explicit_extensions)?;

Ok(final_output)
}
4 changes: 2 additions & 2 deletions packages/qwik/src/optimizer/core/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct TransformCodeOptions<'a> {
pub source_maps: bool,
pub minify: MinifyMode,
pub transpile: bool,
pub explicity_extensions: bool,
pub explicit_extensions: bool,
pub code: &'a str,
pub entry_policy: &'a dyn EntryPolicy,
pub dev: bool,
Expand Down Expand Up @@ -255,7 +255,7 @@ pub fn transform_code(config: TransformCodeOptions) -> Result<TransformOutput, a
let mut qwik_transform = QwikTransform::new(QwikTransformOptions {
path_data: &path_data,
entry_policy: config.entry_policy,
explicity_extensions: config.explicity_extensions,
explicit_extensions: config.explicit_extensions,
extension: extension.clone(),
comments: Some(&comments),
global_collect: collect,
Expand Down
Loading