Skip to content
Open
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
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# shellcheck shell=bash
use flake
watch_file rust-toolchain
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.direnv
target/
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# qwik-optimizer
Qwik Optimizer remake

Qwik Optimizer remake

**_DISCLAIMER_**: This is very much a work in progress so expect this space to change a lot.

## What

This is a ground up re-implementation of the original Qwik Optimzer.

## Why
The decision was made to mover from SWC to Oxide as the foundation for the Qwik Optimizer.

In the process of doing this, we hope to make the internal Qwik Optimizer more modular and to be more idiomatic Rust.
The decision was made to mover from SWC to Oxide as the foundation for the Qwik Optimizer.

In the process of doing this, we hope to make the internal Qwik Optimizer more modular and to be more idiomatic Rust.

## Modules

Expand All @@ -27,3 +28,16 @@ This module currently contains metadata info for components.

Not much save for the unit tests.

## Nix

If you have Nix installed, you can enter a development shell with all the necessary dependencies by running:

```bash
nix develop
```

You can also install `direnv` and have it automatically load the development environment when you enter the project directory:

```bash
direnv allow
```
62 changes: 62 additions & 0 deletions flake.lock

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

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is a Nix configuration file. It is used to define the environment
# for the project. It is a declarative way to define the dependencies.
# It is used by the `nix develop` command to create a development environment
# with all the dependencies needed for the project.

# To update the dependencies, run `nix flake update`.
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = { self, rust-overlay, nixpkgs }:
let
b = builtins;
devShell = system: _pkgs:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
in {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
bashInteractive
gitMinimal

# Provides rustc and cargo
(rust-bin.stable.latest.default.override {
# For rust-analyzer
extensions = [ "rust-src" ];
# For building wasm
targets = [ "wasm32-unknown-unknown" ];
})
];
};
};
in { devShells = b.mapAttrs (devShell) nixpkgs.legacyPackages; };
}
2 changes: 1 addition & 1 deletion optimizer/src/component/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl QrlComponent {
exported_expression: Expression<'_>,
imports: Vec<Import>,
source_type: &SourceType,
source_info: &SourceInfo,
_source_info: &SourceInfo,
allocator: &Allocator,
) -> String {
let name = &id.symbol_name;
Expand Down
2 changes: 1 addition & 1 deletion optimizer/src/component/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Id {
/// - The `scope` (if provided).
///
/// [V 1.0 REF] see `QwikTransform.register_context_name` in `transform.rs.
pub fn new(
pub(crate) fn new(
source_info: &SourceInfo,
segments: &Vec<Segment>,
target: &Target,
Expand Down
4 changes: 2 additions & 2 deletions optimizer/src/component/qrl.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::component::{Import, QRL, QRL_SUFFIX, QWIK_CORE_SOURCE};
use crate::ext::AstBuilderExt;
use oxc_allocator::{Allocator, Box as OxcBox, CloneIn, FromIn, IntoIn, Vec as OxcVec};
use oxc_allocator::{Allocator, Box as OxcBox, CloneIn, FromIn, Vec as OxcVec};
use oxc_ast::ast::*;
use oxc_ast::AstBuilder;
use oxc_semantic::{NodeId, ReferenceFlags, ReferenceId, ScopeId, SymbolFlags, SymbolId};
use oxc_span::{Atom, SPAN};
use oxc_span::SPAN;
use oxc_traverse::TraverseCtx;
use serde::Serialize;
use std::collections::HashMap;
Expand Down
4 changes: 2 additions & 2 deletions optimizer/src/entry_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl PerComponentStrategy {
}

impl EntryPolicy for PerComponentStrategy {
fn get_entry_for_sym(&self, context: &[String], segment: &Segment) -> Option<String> {
fn get_entry_for_sym(&self, _context: &[String], _segment: &Segment) -> Option<String> {
panic!("Not implemented")
/*
context.first().map_or_else(
Expand All @@ -90,7 +90,7 @@ impl SmartStrategy {
}

impl EntryPolicy for SmartStrategy {
fn get_entry_for_sym(&self, context: &[String], segment: &Segment) -> Option<String> {
fn get_entry_for_sym(&self, _context: &[String], _segment: &Segment) -> Option<String> {
panic!("Not implemented")
/*
// Event handlers without scope variables are put into a separate file
Expand Down
2 changes: 1 addition & 1 deletion optimizer/src/illegal_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl IllegalCode for Statement<'_> {
bid.and_then(|bid| bid.symbol_id.get())
.map(|id| IllegalCodeType::Class(id, cd.name().map(String::from)))
}
s => None,
_s => None,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion optimizer/src/import_clean_up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl ImportCleanUp<'_> {
pub fn clean_up<'a>(program: &mut Program<'a>, allocator: &'a Allocator) {
let SemanticBuilderReturn {
semantic,
errors: semantic_errors,
errors: _semantic_errors,
} = SemanticBuilder::new().build(program);

let scoping = semantic.into_scoping();
Expand Down