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 style compilation for file paths containing webpack template strings #1247

Merged
merged 14 commits into from
Feb 1, 2024
Merged
7 changes: 7 additions & 0 deletions .changeset/eleven-oranges-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@vanilla-extract/webpack-plugin': patch
---

Fixes a bug that was causing style compilation to fail on paths containing [webpack template strings] such as `[id]`.

[webpack template strings]: https://webpack.js.org/configuration/output/#template-strings
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
}
},
"volta": {
"node": "20.9.0"
"node": "20.9.0",
"pnpm": "8.10.2"
askoufis marked this conversation as resolved.
Show resolved Hide resolved
askoufis marked this conversation as resolved.
Show resolved Hide resolved
}
}
6 changes: 5 additions & 1 deletion packages/webpack-plugin/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ function compileVanillaSource(
);
const compat = createCompat(isWebpack5);
// Child compiler will compile vanilla-extract files to be evaled during compilation
const outputOptions = { filename: loader.resourcePath };
const outputOptions = {
filename: loader.resourcePath
.replaceAll('[', '[\\')
askoufis marked this conversation as resolved.
Show resolved Hide resolved
.replaceAll(']', '\\]'),
askoufis marked this conversation as resolved.
Show resolved Hide resolved
askoufis marked this conversation as resolved.
Show resolved Hide resolved
};

const compilerName = getCompilerName(loader.resourcePath);
const childCompiler = getRootCompilation(loader).createChildCompiler(
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": ["es2019", "es2017", "dom"],
"lib": ["es2021", "dom"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Required for tsc to recognize replaceAll. It was added in node 15, so IMO it's safe to use.

"noEmit": true,
"noImplicitAny": true,
"noUnusedLocals": true,
Expand Down