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

Allow urls that contain fragments, fixes #560 #561

Merged
merged 1 commit into from Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/parse-styles.js
Expand Up @@ -227,11 +227,6 @@ function isProcessableURL(uri) {
try {
// needs a base to parse properly
const url = new URL(uri, "https://example.com")

if (url.hash) {
return false
}

if (url.search) {
return false
}
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/filter-ignore.css
Expand Up @@ -13,5 +13,4 @@
@import url('//css');
@import url(//css);
@import url('foo.css?query=string');
@import url('foo.css#hash');
content{}
1 change: 0 additions & 1 deletion test/fixtures/filter-ignore.expected.css
Expand Up @@ -14,7 +14,6 @@
@import url('//css');
@import url(//css);
@import url('foo.css?query=string');
@import url('foo.css#hash');
@media (min-width: 25em){
ignore{}
}
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/imports/modules/subpath/a.css
@@ -0,0 +1,3 @@
.foo {
color: green;
}
6 changes: 6 additions & 0 deletions test/fixtures/imports/modules/subpath/package.json
@@ -0,0 +1,6 @@
{
"style": "style.css",
"imports": {
"#a.css": "./a.css"
}
}
1 change: 1 addition & 0 deletions test/fixtures/imports/modules/subpath/style.css
@@ -0,0 +1 @@
@import '#a.css';
1 change: 1 addition & 0 deletions test/fixtures/subpath.css
@@ -0,0 +1 @@
@import "subpath";
3 changes: 3 additions & 0 deletions test/fixtures/subpath.expected.css
@@ -0,0 +1,3 @@
.foo {
color: green;
}
23 changes: 23 additions & 0 deletions test/resolve.js
@@ -1,6 +1,8 @@
"use strict"
// external tooling
const test = require("ava")
const fs = require("fs")
const path = require("path")

// internal tooling
const checkFixture = require("./helpers/check-fixture")
Expand Down Expand Up @@ -72,3 +74,24 @@ test(
{ path: null, addModulesDirectories: ["shared_modules"] },
{ from: "test/fixtures/imports/foo.css" },
)

test(
"should resolve modules with node subpath imports with a custom resolver",
checkFixture,
"subpath",
{
resolve: (id, basedir) => {
// see: https://nodejs.org/api/packages.html#subpath-imports
if (id.startsWith("#")) {
const pkgJSON = JSON.parse(
fs.readFileSync(path.join(basedir, "package.json")),
)

return path.join(basedir, pkgJSON.imports[id])
}

return id
},
path: "test/fixtures/imports/modules",
},
)