Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Stop if rollup can't find import that should be there#1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
levkk merged 1 commit intomasterfromlevkk-fiix-not-found
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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
20 changes: 19 additions & 1 deletionpackages/cargo-pgml-components/Cargo.lock
View file
Open in desktop

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

3 changes: 2 additions & 1 deletionpackages/cargo-pgml-components/Cargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-pgml-components"
version = "0.1.19"
version = "0.1.20"
edition = "2021"
authors = ["PostgresML <team@postgresml.org>"]
license = "MIT"
Expand All@@ -22,6 +22,7 @@ regex = "1"
toml = "0.7"
serde = { version = "1", features = ["derive"] }
file-lock = "2"
serde_json = "1"

[dev-dependencies]
assert_cmd = "2"
Expand Down
32 changes: 29 additions & 3 deletionspackages/cargo-pgml-components/src/frontend/javascript.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
//! Javascript bundling.

use glob::glob;
use std::collections::HashSet;
use std::collections::{HashMap,HashSet};
use std::fs::{copy, read_to_string, remove_file, File};
use std::io::Write;
use std::path::PathBuf;
use std::path::{Path,PathBuf};
use std::process::{exit, Command};

use convert_case::{Case, Casing};
use serde::{Deserialize, Serialize};

use crate::config::Config;
use crate::frontend::tools::execute_with_nvm;
Expand All@@ -32,6 +33,11 @@ static OLD_BUNLDES_GLOB: &'static str = "static/js/*.*.js";
/// JS compiler
static JS_COMPILER: &'static str = "rollup";

#[derive(Serialize, Deserialize, Debug)]
struct Packages {
dependencies: HashMap<String, String>,
}

/// Delete old bundles we may have created.
fn cleanup_old_bundles() {
// Clean up old bundles
Expand DownExpand Up@@ -146,6 +152,16 @@ pub fn bundle(config: Config, minify: bool) {
cleanup_old_bundles();
assemble_modules(config.clone());

let package_json = Path::new("package.json");

let packages: Packages = if package_json.is_file() {
let packages = unwrap_or_exit!(read_to_string(package_json));
unwrap_or_exit!(serde_json::from_str(&packages))
} else {
warn("package.json not found, can't validate rollup output");
serde_json::from_str(r#"{"dependencies": {}}"#).unwrap()
};

let mut command = Command::new(JS_COMPILER);

command
Expand All@@ -163,7 +179,17 @@ pub fn bundle(config: Config, minify: bool) {

// Bundle JavaScript.
info("bundling javascript with rollup");
unwrap_or_exit!(execute_with_nvm(&mut command));
let output = unwrap_or_exit!(execute_with_nvm(&mut command));

let lines = output.split("\n");
for line in lines {
for (package, _version) in &packages.dependencies {
if line.contains(package) {
error(&format!("unresolved import: {}", package));
exit(1);
}
}
}

info(&format!("written {}", JS_FILE));

Expand Down
2 changes: 1 addition & 1 deletionpackages/cargo-pgml-components/src/util.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ pub fn execute_command(command: &mut Command) -> std::io::Result<String> {
info!("{}", stdout);
}

Ok(stdout)
Ok(stdout.clone() + &stderr)
}

pub fn write_to_file(path: &Path, content: &str) -> std::io::Result<()> {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp