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: css @import starting with ~ #1622

Merged
merged 2 commits into from
Jul 17, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-pears-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/core": patch
---

Fix css @import starting with ~
2 changes: 1 addition & 1 deletion crates/plugin_css/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Plugin for FarmPluginCssResolve {
}));
} else if matches!(param.kind, ResolveKind::CssAtImport | ResolveKind::CssUrl) {
// if dep starts with '~', means it's from node_modules.
let source = if let Some(striped_source) = param.source.strip_suffix('~') {
let source = if let Some(striped_source) = param.source.strip_prefix('~') {
striped_source.to_string()
} else {
param.source.clone()
Expand Down
1 change: 1 addition & 0 deletions examples/less/src/index.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import './style/variables.less';
@import '@/style/dep.less';
@import '~@/style/strip.less';

.description {
.description {
Expand Down
3 changes: 3 additions & 0 deletions examples/less/src/style/strip.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dep {
border: 1px solid #000;
}
64 changes: 61 additions & 3 deletions packages/core/binding/binding.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,72 @@ switch (platform) {
}
break
case 'arm':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'farm.linux-arm-musleabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./farm.linux-arm-musleabihf.node')
} else {
nativeBinding = require('@farmfe/core-linux-arm-musleabihf')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'farm.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./farm.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@farmfe/core-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
}
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'farm.linux-riscv64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./farm.linux-riscv64-musl.node')
} else {
nativeBinding = require('@farmfe/core-linux-riscv64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'farm.linux-riscv64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./farm.linux-riscv64-gnu.node')
} else {
nativeBinding = require('@farmfe/core-linux-riscv64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'farm.linux-arm-gnueabihf.node')
join(__dirname, 'farm.linux-s390x-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./farm.linux-arm-gnueabihf.node')
nativeBinding = require('./farm.linux-s390x-gnu.node')
} else {
nativeBinding = require('@farmfe/core-linux-arm-gnueabihf')
nativeBinding = require('@farmfe/core-linux-s390x-gnu')
}
} catch (e) {
loadError = e
Expand Down
2 changes: 1 addition & 1 deletion packages/core/binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export interface ResourcePotRecord {
resources: Array<string>
}
export type JsCompiler = Compiler
export class Compiler {
export declare class Compiler {
constructor(config: object)
traceDependencies(): Array<string>
/** async compile, return promise */
Expand Down
Loading