Skip to content

Commit

Permalink
chore: remove query_string when emit_file to resource_map in `p…
Browse files Browse the repository at this point in the history
…lugin_static_assets` (#1746)

* chore: remove query when emit_file to source_map in plugin_static_assets

* chore: update test
  • Loading branch information
ErKeLost committed Aug 28, 2024
1 parent a0238ff commit 2e7f4f9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-hairs-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/js-plugin-dts": patch
---

remove console
5 changes: 5 additions & 0 deletions .changeset/thick-bats-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/core": patch
---

plugin_static_assets emit resource_map remove query
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//foo-276e63.txt?url:
//foo-276e63.txt:
foo

//index.js:
Expand Down Expand Up @@ -79,4 +79,4 @@
module._m(exports);
exports.default = "/foo-276e63.txt?url";
}
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//foo_bar-47689c.txt?url:
//foo_bar-47689c.txt:
foo_bar

//index.js:
Expand Down Expand Up @@ -90,4 +90,4 @@
"./foo/bar/foo_bar.txt": module.f(_f_foo_bar)
}["./foo/**/*/**"], module.meta.url);
}
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//bar-a57e94.txt?url:
//bar-a57e94.txt:
bar

//foo-8bdf4c.txt?url:
//foo-8bdf4c.txt:
foo

//index.js:
Expand Down Expand Up @@ -94,4 +94,4 @@
"./foo/foo.txt": module.f(_f_foo)
}[`./foo/${foo}`], module.meta.url));
}
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//foo-8bdf4c.txt?url:
//foo-8bdf4c.txt:
foo

//index.js:
Expand Down Expand Up @@ -79,4 +79,4 @@
"./foo/foo.txt": module.f(_f_foo)
}[`./foo/*`], module.meta.url));
}
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806");
6 changes: 5 additions & 1 deletion crates/plugin_static_assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ impl FarmPluginStaticAssets {
)
}
}

fn remove_resource_name_query(name: &str) -> String {
name.split('?').next().unwrap_or(name).to_string()
}
}

impl Plugin for FarmPluginStaticAssets {
Expand Down Expand Up @@ -239,7 +243,7 @@ impl Plugin for FarmPluginStaticAssets {

context.emit_file(EmitFileParams {
resolved_path: param.module_id.clone(),
name: resource_name,
name: Self::remove_resource_name_query(&resource_name),
content: bytes,
resource_type: ResourceType::Asset(ext.to_string()),
});
Expand Down
1 change: 0 additions & 1 deletion js-plugins/dts/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export default class Context {
}))
)
.concat(dtsOutputFiles);
console.log('outputFiles', outputFiles, this.options.outputDir);
let entryRoot = this.options.entryRoot ?? '';
entryRoot =
entryRoot ||
Expand Down

0 comments on commit 2e7f4f9

Please sign in to comment.