Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin_resolve): duplicated querystring on external #2057

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

HelloWorld017
Copy link

Description:

  • When I externalize dependencies with querystring, the query duplicates.
  • For example:
    • import { Astal } from 'gi://Astal?version=4.0
    • with externalizing ['^gi://']
    • yields import { o } from "gi://Astal?version=4.0?version=4.0";

Reproduction:

diff --git a/farm.config.js b/farm.config.js
new file mode 100644
index 0000000..aaa84db
--- /dev/null
+++ b/farm.config.js
@@ -0,0 +1,9 @@
+import { defineConfig } from '@farmfe/core';
+
+export default defineConfig({
+	compilation: {
+		input: { index: './index.js' },
+		output: { targetEnv: 'library' },
+		external: ['^gi://']
+	},
+});
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..0c019aa
--- /dev/null
+++ b/index.js
@@ -0,0 +1,2 @@
+import Astal from "gi://Astal?version=4.0";
+export { Astal };
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..2061134
--- /dev/null
+++ b/package.json
@@ -0,0 +1,17 @@
+{
+  "name": "farm-minimal-external",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "build": "farm build",
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "devDependencies": {
+    "@farmfe/cli": "^1.0.4",
+    "@farmfe/core": "^1.6.4"
+  }
+}

Copy link

changeset-bot bot commented Jan 9, 2025

🦋 Changeset detected

Latest commit: b9eec4d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@farmfe/core Patch
@farmfe-examples/tailwind-next Patch
@farmfe/js-plugin-tailwindcss Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codspeed-hq bot commented Jan 9, 2025

CodSpeed Performance Report

Merging #2057 will create unknown performance changes

Comparing HelloWorld017:fix/external-with-querystring (b9eec4d) with main (a785d6f)

Summary

⚠️ No benchmarks were detected in both the base of the PR and the PR.\

@ErKeLost
Copy link
Member

thanks

@@ -83,7 +83,7 @@ impl Plugin for FarmPluginResolve {
// check external first, if the source is set as external, return it immediately
if external_config.is_external(source) {
return Ok(Some(PluginResolveHookResult {
resolved_path: param.source.clone(),
resolved_path: String::from(source),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should remove remove querystring ?xxx from param.source to resolve this issue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The querystring is removed at line 63:

    // split query from source
    let splits: Vec<&str> = source.split('?').collect();
    let source = splits[0];

But the param.source remains untouched.
So I have changed param.source into the source, which querystring is removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants