Skip to content

Commit e4d054a

Browse files
committed
fix: import with { type: json } and css module parse
1 parent 8f9ec27 commit e4d054a

File tree

7 files changed

+17
-1
lines changed

7 files changed

+17
-1
lines changed

crates/mako/src/ast/css_ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl CssAst {
4343
let config = parser::parser::ParserConfig {
4444
css_modules,
4545
legacy_ie: true,
46+
legacy_nesting: true,
4647
..Default::default()
4748
};
4849

crates/mako/src/ast/js_ast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ impl JsAst {
6161
jsx,
6262
decorators: true,
6363
decorators_before_export: true,
64+
// temporarily parse import xx.json with { type: "json" }
65+
// e.g. https://github.com/zen-fs/core/blob/80d32c4807df4a0e887f5c33afae82fde8e62191/src/index.ts#L19
66+
import_attributes: true,
6467
..Default::default()
6568
})
6669
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.container {
22
padding-top: 80px;
3+
4+
h1 {
5+
font-size: 18px;
6+
}
37
}

e2e/fixtures/css.css-modules/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styles from "./index.css";
22
console.log(styles);
3-
3+
import pkg from "../mako.config.json" with { type: "json"};
4+
console.log(pkg);
45
import('./a.css');
56
require('./b.css');
67
import "./c.css";

e2e/fixtures/json/node_modules/data/foo.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/fixtures/json/node_modules/data/index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/fixtures/json/src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
import json from "./example.json";
2+
import data from "data";
23
console.log(json);
4+
console.log(data)

0 commit comments

Comments
 (0)