Skip to content
Closed
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
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/codegen/src/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ describe('runCMK', () => {
expect(await iff.readFile('generated/src/a.module.css.d.ts')).toMatchInlineSnapshot(`
"// @ts-nocheck
declare const styles = {
a1: '' as readonly string,
'a1': '' as readonly string,
};
export default styles;
"
`);
expect(await iff.readFile('generated/src/b.module.css.d.ts')).toMatchInlineSnapshot(`
"// @ts-nocheck
declare const styles = {
b1: '' as readonly string,
'b1': '' as readonly string,
};
export default styles;
"
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('runCMK', () => {
expect(await iff.readFile('generated/src/a.module.css.d.ts')).toMatchInlineSnapshot(`
"// @ts-nocheck
declare const styles = {
a1: '' as readonly string,
'a1': '' as readonly string,
};
export default styles;
"
Expand Down
62 changes: 31 additions & 31 deletions packages/core/src/dts-creator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ describe('createDts', () => {
},
"mapping": {
"generatedOffsets": [
42,
75,
43,
78,
],
"lengths": [
6,
Expand All @@ -73,8 +73,8 @@ describe('createDts', () => {
},
"text": "// @ts-nocheck
declare const styles = {
local1: '' as readonly string,
local2: '' as readonly string,
'local1': '' as readonly string,
'local2': '' as readonly string,
};
export default styles;
",
Expand Down Expand Up @@ -118,27 +118,27 @@ describe('createDts', () => {
9,
],
"generatedOffsets": [
141,
213,
144,
221,
],
"lengths": [
9,
16,
],
"sourceOffsets": [
89,
154,
90,
160,
],
},
"mapping": {
"generatedOffsets": [
59,
89,
114,
141,
154,
186,
213,
90,
116,
144,
160,
193,
221,
],
"lengths": [
16,
Expand All @@ -162,8 +162,8 @@ describe('createDts', () => {
"text": "// @ts-nocheck
declare const styles = {
...(await import('./a.module.css')).default,
imported1: (await import('./b.module.css')).default.imported1,
aliasedImported2: (await import('./c.module.css')).default.imported2,
'imported1': (await import('./b.module.css')).default['imported1'],
'aliasedImported2': (await import('./c.module.css')).default['imported2'],
};
export default styles;
",
Expand All @@ -189,8 +189,8 @@ describe('createDts', () => {
},
"mapping": {
"generatedOffsets": [
42,
92,
43,
94,
],
"lengths": [
6,
Expand All @@ -203,7 +203,7 @@ describe('createDts', () => {
},
"text": "// @ts-nocheck
declare const styles = {
local1: '' as readonly string,
'local1': '' as readonly string,
...(await import('./a.module.css')).default,
};
export default styles;
Expand Down Expand Up @@ -250,27 +250,27 @@ describe('createDts', () => {
9,
],
"generatedOffsets": [
141,
213,
144,
221,
],
"lengths": [
9,
16,
],
"sourceOffsets": [
89,
154,
90,
160,
],
},
"mapping": {
"generatedOffsets": [
59,
89,
114,
141,
154,
186,
213,
90,
116,
144,
160,
193,
221,
],
"lengths": [
16,
Expand All @@ -294,8 +294,8 @@ describe('createDts', () => {
"text": "// @ts-nocheck
declare const styles = {
...(await import('@/a.module.css')).default,
imported1: (await import('@/b.module.css')).default.imported1,
aliasedImported2: (await import('@/c.module.css')).default.imported2,
'imported1': (await import('@/b.module.css')).default['imported1'],
'aliasedImported2': (await import('@/c.module.css')).default['imported2'],
};
export default styles;
",
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/dts-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ interface LinkedCodeMapping extends CodeMapping {
* ```ts
* // @ts-nocheck
* const styles = {
* local1: '' as readonly string,
* local2: '' as readonly string,
* 'local1': '' as readonly string,
* 'local2': '' as readonly string,
* ...(await import('./a.module.css')).default,
* imported1: (await import('./b.module.css')).default.imported1,
* aliasedImported2: (await import('./b.module.css')).default.imported2,
* 'imported1': (await import('./b.module.css')).default.['imported1'],
* 'aliasedImported2': (await import('./b.module.css')).default['imported2'],
* };
* export default styles;
* ```
Expand Down Expand Up @@ -78,11 +78,11 @@ export function createDts(
let text = `// @ts-nocheck\ndeclare const ${STYLES_EXPORT_NAME} = {\n`;

for (const token of localTokens) {
text += ` `;
text += ` '`;
mapping.sourceOffsets.push(token.loc.start.offset);
mapping.generatedOffsets.push(text.length);
mapping.lengths.push(token.name.length);
text += `${token.name}: '' as readonly string,\n`;
text += `${token.name}': '' as readonly string,\n`;
}
for (const tokenImporter of tokenImporters) {
if (tokenImporter.type === 'import') {
Expand All @@ -97,25 +97,25 @@ export function createDts(
const localName = value.localName ?? value.name;
const localLoc = value.localLoc ?? value.loc;

text += ` `;
text += ` '`;
mapping.sourceOffsets.push(localLoc.start.offset);
mapping.lengths.push(localName.length);
mapping.generatedOffsets.push(text.length);
linkedCodeMapping.sourceOffsets.push(text.length);
linkedCodeMapping.lengths.push(localName.length);
text += `${localName}: (await import(`;
text += `${localName}': (await import(`;
if (i === 0) {
mapping.sourceOffsets.push(tokenImporter.fromLoc.start.offset - 1);
mapping.lengths.push(tokenImporter.from.length + 2);
mapping.generatedOffsets.push(text.length);
}
text += `'${tokenImporter.from}')).default.`;
text += `'${tokenImporter.from}')).default['`;
mapping.sourceOffsets.push(value.loc.start.offset);
mapping.lengths.push(value.name.length);
mapping.generatedOffsets.push(text.length);
linkedCodeMapping.generatedOffsets.push(text.length);
linkedCodeMapping.generatedLengths.push(value.name.length);
text += `${value.name},\n`;
text += `${value.name}'],\n`;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dist"
],
"dependencies": {
"@volar/language-server": "^2.4.11",
"@volar/language-server": "^2.4.13",
"volar-service-css": "^0.0.62"
}
}
4 changes: 2 additions & 2 deletions packages/ts-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"dist"
],
"dependencies": {
"@volar/language-core": "^2.4.11",
"@volar/typescript": "^2.4.11",
"@volar/language-core": "^2.4.13",
"@volar/typescript": "^2.4.13",
"@css-modules-kit/core": "^0.2.0"
},
"peerDependencies": {
Expand Down
Loading