Skip to content

Commit 3fd9af3

Browse files
authored
chore: introduce changesets (#50)
* chore: introduce changesets * fix: typechecking
1 parent 7983b7f commit 3fd9af3

File tree

10 files changed

+577
-13
lines changed

10 files changed

+577
-13
lines changed

.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"typecheck": "pnpm -r typecheck"
1616
},
1717
"devDependencies": {
18+
"@changesets/cli": "^2.28.1",
1819
"@eslint/js": "^9.21.0",
1920
"@types/node": "^22.13.8",
2021
"@vitest/browser": "^3.0.7",

packages/create-lwc/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async function writePackageFile(projectRoot: string, templateDir: string, packag
9090

9191
write(projectRoot, templateDir, 'package.json', JSON.stringify(pkg, null, 2));
9292

93-
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
93+
const pkgInfo = pkgFromUserAgent(process.env['npm_config_user_agent']);
9494
const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
9595

9696
if (pkgManager === 'yarn') {
@@ -101,7 +101,7 @@ async function writePackageFile(projectRoot: string, templateDir: string, packag
101101

102102
return pkgManager;
103103
}
104-
function logResult(projectRoot: string, pkgManager: string) {
104+
function logResult(projectRoot: string, pkgManager?: string) {
105105
console.log(`\nDone. Now run:\n`);
106106
if (projectRoot !== cwd) {
107107
console.log(` cd ${path.relative(cwd, projectRoot)}`);

packages/create-lwc/src/utils.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,21 @@ function copyDir(srcDir: string, destDir: string) {
6464
}
6565
}
6666
export function pkgFromUserAgent(userAgent: string | undefined): {
67-
name: string;
68-
version: string;
67+
name: string | undefined;
68+
version: string | undefined;
6969
} | undefined {
7070
if (!userAgent)
7171
return undefined;
72+
7273
const pkgSpec = userAgent.split(' ')[0];
73-
const pkgSpecArr = pkgSpec.split('/');
74+
75+
const pkgSpecArr = pkgSpec?.split('/');
76+
77+
78+
7479
return {
75-
name: pkgSpecArr[0],
76-
version: pkgSpecArr[1],
80+
name: pkgSpecArr?.[0],
81+
version: pkgSpecArr?.[1],
7782
};
7883
}
7984

packages/vite-plugin-lwc/CHANGELOG.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
# 5.0.0
1+
# 4.0.0
22

3-
-
3+
## 4.0.1
44

5-
# 4.0.0
5+
### Patch Changes
6+
7+
- Set defaultModules = [] if unspecified
68
- move vite to peerDependencies
79
- move @lwc/rollup-plugin to peerDependencies
810
- remove rollup from dependencies
911

1012
# 3.0.0
13+
1114
- update vite to 6.0.11
1215
- update vitest to 3.0.4
1316
- update rollup to 4.32.0

packages/vite-plugin-lwc/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-lwc",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"license": "MIT",
55
"author": "Matheus Cardoso <[email protected]>",
66
"maintainers": [

packages/vite-plugin-lwc/src/lwc.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export interface ViteLwcOptions extends RollupLwcOptions {
77
exclude?: FilterPattern;
88
}
99

10+
interface Options extends ViteLwcOptions {
11+
[key: string]: unknown;
12+
}
13+
1014
function createRollupPlugin(options: RollupLwcOptions) {
1115
const plugin = lwc(options);
1216

@@ -24,8 +28,8 @@ function createRollupPlugin(options: RollupLwcOptions) {
2428
};
2529
}
2630

27-
export default function lwcVite(config: ViteLwcOptions): Plugin {
28-
config.rootDir ??= ".";
31+
export default function lwcVite(rawConfig: ViteLwcOptions): Plugin {
32+
const config = createConfig(rawConfig);
2933
const csr = createRollupPlugin(config);
3034
const ssr = createRollupPlugin({ ...config, targetSSR: true });
3135

@@ -112,6 +116,13 @@ export default function lwcVite(config: ViteLwcOptions): Plugin {
112116
};
113117
}
114118

119+
function createConfig(rawConfig: ViteLwcOptions): Options {
120+
const config = rawConfig as Options;
121+
config.rootDir ??= ".";
122+
config['defaultModules'] ??= [];
123+
return config;
124+
}
125+
115126
function getError(
116127
error: unknown,
117128
id?: string,

0 commit comments

Comments
 (0)