Skip to content

Commit

Permalink
Merge branch 'main' into qwikPanda
Browse files Browse the repository at this point in the history
  • Loading branch information
gioboa committed Mar 25, 2024
2 parents 2d0bded + cf86daa commit 434f931
Show file tree
Hide file tree
Showing 33 changed files with 6,072 additions and 6,045 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ lint:
test:
cargo test

test-update:
if ! cargo test; then \
cd packages/qwik/src/optimizer/core/src/snapshots/ && for i in *.new; do f=$$(basename $$i .new); mv $$i $$f; done; \
cargo test; \
fi

publish-core:
cd src/optimizer/core && cargo publish --all-features

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/cloudflare.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/cloudflare.yml/badge.svg" alt="Cloudflare Pages Server"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/netlify.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/netlify.yml/badge.svg" alt="Netlify Server"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/node.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/node.yml/badge.svg" alt="Node Servers"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/vercel.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/vercel.yml/badge.svg" alt="Vercel Server"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/vercel-edge.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/vercel-edge.yml/badge.svg" alt="Vercel Edge"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/vercel-serverless.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/vercel-serverless.yml/badge.svg" alt="Vercel Serverless"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/cli.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/cli.yml/badge.svg" alt="Create Qwik CLI"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/deno.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/deno.yml/badge.svg" alt="Deno Server"></a>
<a href="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/aws.yml"><img src="https://github.com/BuilderIO/qwik-city-e2e/actions/workflows/aws.yml/badge.svg" alt="AWS Server"></a>
Expand Down
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# Provides rustc and cargo
((rust-bin.fromRustupToolchainFile
./rust-toolchain).override {
# For rust-analyzer
extensions = [ "rust-src" ];
# For building wasm
targets = [ "wasm32-unknown-unknown" ];
})
];
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
"test.e2e.firefox": "playwright test starters --browser=firefox --config starters/playwright.config.ts",
"test.e2e.webkit": "playwright test starters --browser=webkit --config starters/playwright.config.ts",
"test.rust": "make test",
"test.rust.update": "make test-update",
"test.unit": "vitest packages",
"test.unit.debug": "vitest --inspect-brk packages",
"test.vite": "playwright test starters/e2e/qwikcity --browser=chromium --config starters/playwright.config.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/adapters/cloudflare-pages/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default extendConfig(baseConfig, () => {
exclude: ['/demo/*', '/shop/*'],
origin:
(process.env.CF_PAGES_BRANCH !== 'main' ? process.env.CF_PAGES_URL : null) ??
'https://qwik.dev',
'https://qwik.builder.io',
},
}),
],
Expand Down
Binary file modified packages/docs/public/logos/social-card.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/docs/src/components/builder-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function getBuilderContent({
);
qwikUrl.searchParams.set('apiKey', apiKey);
qwikUrl.searchParams.set('userAttributes.urlPath', urlPath);
qwikUrl.searchParams.set('userAttributes.site', 'qwik.dev');
qwikUrl.searchParams.set('userAttributes.site', 'qwik.builder.io');
if (cacheBust) {
qwikUrl.searchParams.set('cachebust', 'true');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contributors:
- igorbabko
- mrhoodz
- dario-piotrowicz
- matthewlal
updated_at: '2023-10-03T18:53:23Z'
created_at: '2023-04-06T21:28:28Z'
---
Expand Down Expand Up @@ -38,6 +39,14 @@ The adapter will add a new `vite.config.ts` within the `adapters/` directory, an

Additionally, within the `package.json`, the `build.server` and `deploy` scripts will be updated.

Take note of your nodejs version in your local environment by running the `node -v` command:
```shell
node -v
v20.11.1
```

When using `npm create qwik@latest` to setup your Qwik app it will likely use a different nodejs version than what Cloudflare Pages uses by default (v16.20.2).

## Production build

To build the application for production, use the `build` command, this command will automatically run `npm run build.server` and `npm run build.client`:
Expand All @@ -52,6 +61,15 @@ npm run build

After installing the integration using `npm run qwik add cloudflare-pages`, the project is ready to be deployed to Cloudflare Pages.

If the nodejs version is different in your environment than Cloudflare Pages (v16.20.2) you'll need to add a `NODE_VERSION` environment variable and set the value to the version that you got from running the `node -v` command in your environment:

```shell
node -v
v20.11.1
```

To do this in Cloudflare go to **Workers & Pages > YOUR_PROJECT > Settings > Environment variables > Production (and Preview) > Add variables > Save **

Please refer to the [Cloudflare Pages docs](https://developers.cloudflare.com/pages/framework-guides/deploy-a-qwik-site/) for more information on how to deploy your site.

Note that you will need a [Cloudflare account](https://dash.cloudflare.com/sign-up?lang=en-US) in order to complete this step.
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/napi/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate napi_build;

fn main() {
napi_build::setup();
napi_build::setup();
}
22 changes: 11 additions & 11 deletions packages/qwik/src/napi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[allow(clippy::needless_pass_by_value)]
#[js_function(1)]
fn transform_fs(ctx: CallContext) -> Result<JsUnknown> {
let opts = ctx.get::<JsObject>(0)?;
let config: qwik_core::TransformFsOptions = ctx.env.from_js_value(opts)?;
let opts = ctx.get::<JsObject>(0)?;
let config: qwik_core::TransformFsOptions = ctx.env.from_js_value(opts)?;

let result = qwik_core::transform_fs(config).unwrap();
ctx.env.to_js_value(&result)
let result = qwik_core::transform_fs(config).unwrap();
ctx.env.to_js_value(&result)
}

#[allow(clippy::needless_pass_by_value)]
#[js_function(1)]
fn transform_modules(ctx: CallContext) -> Result<JsUnknown> {
let opts = ctx.get::<JsObject>(0)?;
let config: qwik_core::TransformModulesOptions = ctx.env.from_js_value(opts)?;
let opts = ctx.get::<JsObject>(0)?;
let config: qwik_core::TransformModulesOptions = ctx.env.from_js_value(opts)?;

let result = qwik_core::transform_modules(config).unwrap();
ctx.env.to_js_value(&result)
let result = qwik_core::transform_modules(config).unwrap();
ctx.env.to_js_value(&result)
}

#[module_exports]
fn init(mut exports: JsObject) -> Result<()> {
exports.create_named_method("transform_fs", transform_fs)?;
exports.create_named_method("transform_modules", transform_modules)?;
exports.create_named_method("transform_fs", transform_fs)?;
exports.create_named_method("transform_modules", transform_modules)?;

Ok(())
Ok(())
}
172 changes: 86 additions & 86 deletions packages/qwik/src/optimizer/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ use path_absolutize::Absolutize;
use qwik_core::{transform_fs, EmitMode, EntryStrategy, MinifyMode, TransformFsOptions};

struct OptimizerInput {
glob: Option<String>,
manifest: Option<String>,
core_module: Option<String>,
scope: Option<String>,
src: PathBuf,
dest: PathBuf,
mode: EmitMode,
strategy: EntryStrategy,
transpile_ts: bool,
transpile_jsx: bool,
preserve_filenames: bool,
minify: MinifyMode,
sourcemaps: bool,
explicit_extensions: bool,
glob: Option<String>,
manifest: Option<String>,
core_module: Option<String>,
scope: Option<String>,
src: PathBuf,
dest: PathBuf,
mode: EmitMode,
strategy: EntryStrategy,
transpile_ts: bool,
transpile_jsx: bool,
preserve_filenames: bool,
minify: MinifyMode,
sourcemaps: bool,
explicit_extensions: bool,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
let matches = Command::new("qwik")
let matches = Command::new("qwik")
.version("1.0")
.arg_required_else_help(true)
.subcommand_required(true)
Expand Down Expand Up @@ -85,85 +85,85 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.get_matches();

// You can check for the existence of subcommands, and if found use their
// matches just as you would the top level app
if let Some(matches) = matches.subcommand_matches("optimize") {
// "$ myapp test" was run
let strategy = match matches.value_of("strategy") {
Some("inline") => EntryStrategy::Inline,
Some("hook") => EntryStrategy::Hook,
Some("single") => EntryStrategy::Single,
Some("component") => EntryStrategy::Component,
Some("smart") | None => EntryStrategy::Smart,
_ => panic!("Invalid strategy option"),
};
// You can check for the existence of subcommands, and if found use their
// matches just as you would the top level app
if let Some(matches) = matches.subcommand_matches("optimize") {
// "$ myapp test" was run
let strategy = match matches.value_of("strategy") {
Some("inline") => EntryStrategy::Inline,
Some("hook") => EntryStrategy::Hook,
Some("single") => EntryStrategy::Single,
Some("component") => EntryStrategy::Component,
Some("smart") | None => EntryStrategy::Smart,
_ => panic!("Invalid strategy option"),
};

let minify = match matches.value_of("minify") {
Some("none") => MinifyMode::None,
Some("simplify") | None => MinifyMode::Simplify,
_ => panic!("Invalid minify option"),
};
let minify = match matches.value_of("minify") {
Some("none") => MinifyMode::None,
Some("simplify") | None => MinifyMode::Simplify,
_ => panic!("Invalid minify option"),
};

let mode = match matches.value_of("mode") {
Some("dev") => EmitMode::Dev,
Some("prod") => EmitMode::Prod,
Some("lib") | None => EmitMode::Lib,
_ => panic!("Invalid mode option"),
};
optimize(OptimizerInput {
src: matches.value_of_t_or_exit("src"),
dest: matches.value_of_t_or_exit("dest"),
manifest: matches.value_of("manifest").map(|s| s.into()),
core_module: matches.value_of("core_module").map(|s| s.into()),
scope: matches.value_of("scope").map(|s| s.into()),
mode,
glob: None,
strategy,
minify,
explicit_extensions: matches.is_present("extensions"),
transpile_jsx: !matches.is_present("no-jsx"),
transpile_ts: !matches.is_present("no-ts"),
preserve_filenames: matches.is_present("preserve-filenames"),
sourcemaps: matches.is_present("sourcemaps"),
})?;
}
Ok(())
let mode = match matches.value_of("mode") {
Some("dev") => EmitMode::Dev,
Some("prod") => EmitMode::Prod,
Some("lib") | None => EmitMode::Lib,
_ => panic!("Invalid mode option"),
};
optimize(OptimizerInput {
src: matches.value_of_t_or_exit("src"),
dest: matches.value_of_t_or_exit("dest"),
manifest: matches.value_of("manifest").map(|s| s.into()),
core_module: matches.value_of("core_module").map(|s| s.into()),
scope: matches.value_of("scope").map(|s| s.into()),
mode,
glob: None,
strategy,
minify,
explicit_extensions: matches.is_present("extensions"),
transpile_jsx: !matches.is_present("no-jsx"),
transpile_ts: !matches.is_present("no-ts"),
preserve_filenames: matches.is_present("preserve-filenames"),
sourcemaps: matches.is_present("sourcemaps"),
})?;
}
Ok(())
}

fn optimize(
optimizer_input: OptimizerInput,
optimizer_input: OptimizerInput,
) -> Result<qwik_core::TransformOutput, Box<dyn std::error::Error>> {
let current_dir = std::env::current_dir()?;
let src_dir = current_dir.join(optimizer_input.src).canonicalize()?;
let current_dir = std::env::current_dir()?;
let src_dir = current_dir.join(optimizer_input.src).canonicalize()?;

let result = transform_fs(TransformFsOptions {
src_dir: src_dir.to_string_lossy().to_string(),
vendor_roots: vec![],
glob: optimizer_input.glob,
source_maps: optimizer_input.sourcemaps,
minify: optimizer_input.minify,
transpile_jsx: optimizer_input.transpile_jsx,
transpile_ts: optimizer_input.transpile_ts,
preserve_filenames: optimizer_input.preserve_filenames,
entry_strategy: optimizer_input.strategy,
explicit_extensions: optimizer_input.explicit_extensions,
core_module: optimizer_input.core_module,
root_dir: None,
let result = transform_fs(TransformFsOptions {
src_dir: src_dir.to_string_lossy().to_string(),
vendor_roots: vec![],
glob: optimizer_input.glob,
source_maps: optimizer_input.sourcemaps,
minify: optimizer_input.minify,
transpile_jsx: optimizer_input.transpile_jsx,
transpile_ts: optimizer_input.transpile_ts,
preserve_filenames: optimizer_input.preserve_filenames,
entry_strategy: optimizer_input.strategy,
explicit_extensions: optimizer_input.explicit_extensions,
core_module: optimizer_input.core_module,
root_dir: None,

mode: optimizer_input.mode,
scope: optimizer_input.scope,
mode: optimizer_input.mode,
scope: optimizer_input.scope,

manual_chunks: None,
strip_exports: None,
strip_ctx_name: None,
strip_event_handlers: false,
reg_ctx_name: None,
is_server: None,
})?;
manual_chunks: None,
strip_exports: None,
strip_ctx_name: None,
strip_event_handlers: false,
reg_ctx_name: None,
is_server: None,
})?;

result.write_to_fs(
&current_dir.join(optimizer_input.dest).absolutize()?,
optimizer_input.manifest,
)?;
Ok(result)
result.write_to_fs(
&current_dir.join(optimizer_input.dest).absolutize()?,
optimizer_input.manifest,
)?;
Ok(result)
}
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 @@ -7,7 +7,7 @@ use test::Bencher;

#[bench]
fn transform_todo_app(b: &mut Bencher) {
b.iter(|| {
b.iter(|| {
let code = r#"
import {
Fragment,
Expand Down
Loading

0 comments on commit 434f931

Please sign in to comment.