-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support obj external & dts support resolvedPaths (#1282)
* feat: support obj external & dts support resolvedPaths * fix: test case * fix: dts file ext * fix: window path match * chore: remove print * fix: avoid break change * feat: clean code --------- Co-authored-by: brightwu <[email protected]>
- Loading branch information
1 parent
9703b9d
commit df7ac2a
Showing
57 changed files
with
1,338 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@farmfe/js-plugin-dts': patch | ||
--- | ||
|
||
support custom resolvedPaths & reduce product size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@farmfe/core': patch | ||
--- | ||
|
||
support record external |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"editor.inlineSuggest.showToolbar": "always" | ||
"editor.inlineSuggest.showToolbar": "always", | ||
"biome.enabled": true, | ||
"prettier.enable": false, | ||
"editor.defaultFormatter": "biomejs.biome", | ||
"[typescript]": { | ||
"editor.defaultFormatter": "biomejs.biome", | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "biomejs.biome", | ||
}, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
mod common; | ||
use crate::common::{assert_compiler_result, create_compiler_with_args}; | ||
use std::{collections::HashMap, path::PathBuf}; | ||
|
||
use farmfe_core::config::{ | ||
config_regex::ConfigRegex, custom::CUSTOM_CONFIG_EXTERNAL_RECORD, ModuleFormat, TargetEnv, | ||
}; | ||
|
||
fn test(file: String, crate_path: String) { | ||
let file_path_buf = PathBuf::from(file.clone()); | ||
let create_path_buf = PathBuf::from(crate_path); | ||
let cwd = file_path_buf.parent().unwrap(); | ||
println!("testing test case: {:?}", cwd); | ||
|
||
let entry_name = "index".to_string(); | ||
let normolized_file = file.replace('\\', "/"); | ||
let compiler = | ||
create_compiler_with_args(cwd.to_path_buf(), create_path_buf, |mut config, plugins| { | ||
config.input = HashMap::from_iter(vec![(entry_name.clone(), file.clone())]); | ||
|
||
if normolized_file.contains("/browser/") || normolized_file.contains("/node/") { | ||
config.output.target_env = if normolized_file.contains("browser") { | ||
TargetEnv::Browser | ||
} else { | ||
TargetEnv::Node | ||
}; | ||
} | ||
|
||
if normolized_file.contains("/normal/") || normolized_file.contains("/object/") || true { | ||
if normolized_file.contains("/object") { | ||
config | ||
.custom | ||
.entry(CUSTOM_CONFIG_EXTERNAL_RECORD.to_string()) | ||
.or_insert( | ||
r#" | ||
{ | ||
"jquery": "$" | ||
} | ||
"# | ||
.to_string(), | ||
); | ||
} else { | ||
config.external = vec![ConfigRegex::new("^jquery$")]; | ||
} | ||
} | ||
|
||
if normolized_file.contains("/cjs/") || normolized_file.contains("/esm/") { | ||
config.output.format = if normolized_file.contains("cjs") { | ||
ModuleFormat::CommonJs | ||
} else { | ||
ModuleFormat::EsModule | ||
}; | ||
} | ||
|
||
(config, plugins) | ||
}); | ||
|
||
compiler.compile().unwrap(); | ||
|
||
assert_compiler_result(&compiler, Some(&entry_name)); | ||
} | ||
|
||
farmfe_testing::testing! {"tests/fixtures/external/**/*.ts", test} |
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/external/browser/normal/cjs/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import $ from 'jquery'; | ||
|
||
console.log($.find); |
14 changes: 14 additions & 0 deletions
14
crates/compiler/tests/fixtures/external/browser/normal/cjs/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/external/browser/normal/esm/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import $ from 'jquery'; | ||
|
||
console.log($.find); |
14 changes: 14 additions & 0 deletions
14
crates/compiler/tests/fixtures/external/browser/normal/esm/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/external/browser/object/cjs/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import $ from 'jquery'; | ||
|
||
console.log($.find); |
14 changes: 14 additions & 0 deletions
14
crates/compiler/tests/fixtures/external/browser/object/cjs/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/external/browser/object/esm/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import $ from 'jquery'; | ||
|
||
console.log($.find); |
14 changes: 14 additions & 0 deletions
14
crates/compiler/tests/fixtures/external/browser/object/esm/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/external/node/normala/cjs/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import $ from 'jquery'; | ||
|
||
console.log($.find); |
14 changes: 14 additions & 0 deletions
14
crates/compiler/tests/fixtures/external/node/normala/cjs/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/external/node/normala/esm/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import $ from 'jquery'; | ||
|
||
console.log($.find); |
14 changes: 14 additions & 0 deletions
14
crates/compiler/tests/fixtures/external/node/normala/esm/output.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.