Skip to content

Commit cf2ba4d

Browse files
committed
7.1.0 release
2 parents 58e5a65 + d6a9510 commit cf2ba4d

File tree

5 files changed

+2588
-3174
lines changed

5 files changed

+2588
-3174
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 7.1.0 (July 18, 2025)
2+
3+
### pack
4+
5+
* Added `@daltontan/postcss-import-json` PostCSS plugin to process JSON imports in CSS.
6+
* Fixed `eslintWebpackPluginConfig` to not always run lint in strict mode when `enact pack`.
7+
18
## 7.0.0 (June 10, 2025)
29

310
* Updated dependencies.

config/eslintWebpackPluginConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const hasJsxRuntime = (() => {
1515
}
1616
})();
1717

18-
const loadedEnactConfig = process.env.FRAMEWORK ? eslintConfigEnactStrict : eslintConfigEnact;
18+
const loadedEnactConfig = process.env.FRAMEWORK === true ? eslintConfigEnactStrict : eslintConfigEnact;
1919

2020
module.exports = [
2121
...loadedEnactConfig,

config/webpack.config.js

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,98 @@ module.exports = function (
146146
// the browserslist targets.
147147
!useTailwind && require('postcss-normalize'),
148148
// Resolution indepedence support
149-
app.ri !== false && require('postcss-resolution-independence')(app.ri)
149+
app.ri !== false && require('postcss-resolution-independence')(app.ri),
150+
// Support importing JSON files with ~ alias - custom plugin (must run first)
151+
{
152+
postcssPlugin: 'postcss-import-json-tilde',
153+
Once(root) {
154+
// Process all @import-json rules with ~ prefix first, before other plugins
155+
root.walkAtRules('import-json', atRule => {
156+
let src = atRule.params.slice(1, -1); // Remove quotes
157+
158+
// Only handle ~ alias paths
159+
if (src.startsWith('~')) {
160+
const packagePath = src.substring(1); // Remove ~
161+
162+
try {
163+
// Use Node.js standard module resolution
164+
// This mimics webpack's ~ alias behavior
165+
const currentFileDir = path.dirname(atRule.source.input.file || '');
166+
167+
// Try to resolve the module using require.resolve
168+
// This follows standard Node.js module resolution algorithm
169+
let resolvedPath;
170+
try {
171+
// First try from current file's directory
172+
resolvedPath = require.resolve(packagePath, {
173+
paths: [currentFileDir]
174+
});
175+
} catch (e) {
176+
// Fallback to current working directory
177+
resolvedPath = require.resolve(packagePath, {
178+
paths: [process.cwd()]
179+
});
180+
}
181+
182+
// Convert to relative path for the original plugin
183+
const relativePath = path.relative(currentFileDir, resolvedPath);
184+
atRule.params = `"${relativePath}"`;
185+
} catch (error) {
186+
// If resolution fails, try manual node_modules lookup
187+
try {
188+
let currentDir = path.dirname(
189+
atRule.source.input.file || process.cwd()
190+
);
191+
let found = false;
192+
193+
// Walk up directories to find node_modules
194+
while (currentDir !== path.parse(currentDir).root && !found) {
195+
const moduleDir = path.join(
196+
currentDir,
197+
'node_modules',
198+
packagePath
199+
);
200+
if (fs.existsSync(moduleDir)) {
201+
const relativePath = path.relative(
202+
path.dirname(atRule.source.input.file || ''),
203+
moduleDir
204+
);
205+
atRule.params = `"${relativePath}"`;
206+
found = true;
207+
break;
208+
}
209+
currentDir = path.dirname(currentDir);
210+
}
211+
212+
if (!found) {
213+
console.warn(`Could not resolve module path: ${packagePath}`);
214+
}
215+
} catch (fallbackError) {
216+
console.warn(
217+
`Failed to resolve ${packagePath}:`,
218+
fallbackError.message
219+
);
220+
}
221+
}
222+
}
223+
});
224+
}
225+
},
226+
// Support importing JSON files in CSS - original plugin (for non-~ paths)
227+
[
228+
'@daltontan/postcss-import-json',
229+
{
230+
map: (selector, value) => {
231+
if (typeof value === 'object' && value !== null && value.$ref) {
232+
const tokenPath = value.$ref.split('#/')[1];
233+
const cssVariableName = '--' + tokenPath.replace(/\//g, '-');
234+
235+
return `var(${cssVariableName})`;
236+
}
237+
return value;
238+
}
239+
}
240+
]
150241
].filter(Boolean)
151242
},
152243
sourceMap: shouldUseSourceMap

0 commit comments

Comments
 (0)