@css-modules-kit/core 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checker.d.ts +9 -2
- package/dist/checker.d.ts.map +1 -1
- package/dist/checker.js +15 -14
- package/dist/checker.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -24
- package/dist/config.js.map +1 -1
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +9 -15
- package/dist/diagnostic.js.map +1 -1
- package/dist/dts-generator.d.ts +2 -6
- package/dist/dts-generator.d.ts.map +1 -1
- package/dist/dts-generator.js +211 -63
- package/dist/dts-generator.js.map +1 -1
- package/dist/error.js +2 -7
- package/dist/error.js.map +1 -1
- package/dist/export-builder.js +1 -4
- package/dist/export-builder.js.map +1 -1
- package/dist/file.js +17 -30
- package/dist/file.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -44
- package/dist/index.js.map +1 -1
- package/dist/parser/at-import-parser.js +3 -9
- package/dist/parser/at-import-parser.js.map +1 -1
- package/dist/parser/at-value-parser.js +1 -4
- package/dist/parser/at-value-parser.js.map +1 -1
- package/dist/parser/css-module-parser.js +15 -21
- package/dist/parser/css-module-parser.js.map +1 -1
- package/dist/parser/key-frame-parser.js +1 -4
- package/dist/parser/key-frame-parser.js.map +1 -1
- package/dist/parser/rule-parser.js +7 -13
- package/dist/parser/rule-parser.js.map +1 -1
- package/dist/path.d.ts +0 -1
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +16 -31
- package/dist/path.js.map +1 -1
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +13 -40
- package/dist/resolver.js.map +1 -1
- package/dist/type.d.ts +1 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js +1 -2
- package/dist/util.d.ts +1 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +6 -8
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
- package/src/checker.ts +19 -16
- package/src/config.ts +13 -0
- package/src/diagnostic.ts +2 -0
- package/src/dts-generator.ts +216 -66
- package/src/index.ts +3 -2
- package/src/path.ts +0 -3
- package/src/resolver.ts +7 -29
- package/src/type.ts +1 -1
- package/src/typing/typescript.d.ts +1 -1
- package/src/util.ts +4 -0
package/dist/dts-generator.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.STYLES_EXPORT_NAME = void 0;
|
|
4
|
-
exports.generateDts = generateDts;
|
|
5
|
-
const util_js_1 = require("./util.js");
|
|
6
|
-
exports.STYLES_EXPORT_NAME = 'styles';
|
|
1
|
+
import { isURLSpecifier, isValidAsJSIdentifier } from './util.js';
|
|
2
|
+
export const STYLES_EXPORT_NAME = 'styles';
|
|
7
3
|
/**
|
|
8
4
|
* Generate .d.ts from `CSSModule`.
|
|
9
5
|
*/
|
|
10
|
-
function generateDts(cssModule,
|
|
6
|
+
export function generateDts(cssModule, options) {
|
|
11
7
|
// Exclude invalid tokens
|
|
12
8
|
const localTokens = cssModule.localTokens.filter((token) => isValidName(token.name, options));
|
|
13
9
|
const tokenImporters = cssModule.tokenImporters
|
|
@@ -24,10 +20,43 @@ function generateDts(cssModule, host, options) {
|
|
|
24
20
|
return tokenImporter;
|
|
25
21
|
}
|
|
26
22
|
})
|
|
27
|
-
// Exclude token importers for external files
|
|
28
23
|
.filter((tokenImporter) => {
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
/**
|
|
25
|
+
* In principle, token importers with specifiers that cannot be resolved are still included in the type
|
|
26
|
+
* definitions. For example, consider the following:
|
|
27
|
+
*
|
|
28
|
+
* ```css
|
|
29
|
+
* // src/a.module.css
|
|
30
|
+
* @import './unresolved.module.css';
|
|
31
|
+
* @import './unmatched.css';
|
|
32
|
+
* .a_1 { color: red; }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* In this case, CSS Modules Kit generates the following type definitions:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* // generated/src/a.module.css.d.ts
|
|
39
|
+
* // @ts-nocheck
|
|
40
|
+
* declare const styles = {
|
|
41
|
+
* a_1: '' as readonly string,
|
|
42
|
+
* ...(await import('./unresolved.module.css')).default,
|
|
43
|
+
* ...(await import('./unmatched.css')).default,
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Even if `./unresolved.module.css` or `./unmatched.css` does not exist, the same type definitions are
|
|
48
|
+
* generated. It is important that the generated type definitions do not change depending on whether the
|
|
49
|
+
* files exist. This provides the following benefits:
|
|
50
|
+
*
|
|
51
|
+
* - Simplifies the watch mode implementation
|
|
52
|
+
* - Only the type definitions for changed files need to be regenerated
|
|
53
|
+
* - Makes it easier to parallelize code generation
|
|
54
|
+
* - Type definitions can be generated independently per file
|
|
55
|
+
*
|
|
56
|
+
* However, as an exception, URL specifiers are not included in the type definitions, because URL
|
|
57
|
+
* specifiers are typically resolved at runtime.
|
|
58
|
+
*/
|
|
59
|
+
return !isURLSpecifier(tokenImporter.from);
|
|
31
60
|
});
|
|
32
61
|
if (options.namedExports) {
|
|
33
62
|
return generateNamedExportsDts(localTokens, tokenImporters, options);
|
|
@@ -36,28 +65,7 @@ function generateDts(cssModule, host, options) {
|
|
|
36
65
|
return generateDefaultExportDts(localTokens, tokenImporters);
|
|
37
66
|
}
|
|
38
67
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Generate a d.ts file with named exports.
|
|
41
|
-
* @example
|
|
42
|
-
* If the CSS module file is:
|
|
43
|
-
* ```css
|
|
44
|
-
* @import './a.module.css';
|
|
45
|
-
* @value local1: string;
|
|
46
|
-
* @value imported1, imported2 as aliasedImported2 from './b.module.css';
|
|
47
|
-
* .local2 { color: red }
|
|
48
|
-
* ```
|
|
49
|
-
* The d.ts file would be:
|
|
50
|
-
* ```ts
|
|
51
|
-
* // @ts-nocheck
|
|
52
|
-
* export var local1: string;
|
|
53
|
-
* export var local2: string;
|
|
54
|
-
* export * from './a.module.css';
|
|
55
|
-
* export {
|
|
56
|
-
* imported1,
|
|
57
|
-
* imported2 as aliasedImported2,
|
|
58
|
-
* } from './b.module.css';
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
68
|
+
/** Generate a d.ts file with named exports. */
|
|
61
69
|
function generateNamedExportsDts(localTokens, tokenImporters, options) {
|
|
62
70
|
const mapping = { sourceOffsets: [], lengths: [], generatedOffsets: [] };
|
|
63
71
|
const linkedCodeMapping = {
|
|
@@ -73,6 +81,24 @@ function generateNamedExportsDts(localTokens, tokenImporters, options) {
|
|
|
73
81
|
// Therefore, `@ts-nocheck` is added to the generated type definition file.
|
|
74
82
|
let text = `// @ts-nocheck\n`;
|
|
75
83
|
for (const token of localTokens) {
|
|
84
|
+
/**
|
|
85
|
+
* The mapping is created as follows:
|
|
86
|
+
* a.module.css:
|
|
87
|
+
* 1 | .a_1 { color: red; }
|
|
88
|
+
* | ^ mapping.sourceOffsets[0]
|
|
89
|
+
* |
|
|
90
|
+
* 2 | .a_2 { color: blue; }
|
|
91
|
+
* | ^ mapping.sourceOffsets[1]
|
|
92
|
+
* |
|
|
93
|
+
*
|
|
94
|
+
* a.module.css.d.ts:
|
|
95
|
+
* 1 | // @ts-nocheck
|
|
96
|
+
* 2 | export var a_1: string;
|
|
97
|
+
* | ^ mapping.generatedOffsets[0]
|
|
98
|
+
* |
|
|
99
|
+
* 3 | export var a_2: string;
|
|
100
|
+
* | ^ mapping.generatedOffsets[1]
|
|
101
|
+
*/
|
|
76
102
|
text += `export var `;
|
|
77
103
|
mapping.sourceOffsets.push(token.loc.start.offset);
|
|
78
104
|
mapping.generatedOffsets.push(text.length);
|
|
@@ -81,6 +107,26 @@ function generateNamedExportsDts(localTokens, tokenImporters, options) {
|
|
|
81
107
|
}
|
|
82
108
|
for (const tokenImporter of tokenImporters) {
|
|
83
109
|
if (tokenImporter.type === 'import') {
|
|
110
|
+
/**
|
|
111
|
+
* The mapping is created as follows:
|
|
112
|
+
* a.module.css:
|
|
113
|
+
* 1 | @import './b.module.css';
|
|
114
|
+
* | ^ mapping.sourceOffsets[0]
|
|
115
|
+
* |
|
|
116
|
+
* 2 | @import './c.module.css';
|
|
117
|
+
* | ^ mapping.sourceOffsets[1]
|
|
118
|
+
* |
|
|
119
|
+
*
|
|
120
|
+
* a.module.css.d.ts:
|
|
121
|
+
* 1 | // @ts-nocheck
|
|
122
|
+
* 2 | export * from './b.module.css';
|
|
123
|
+
* | ^ mapping.generatedOffsets[0]
|
|
124
|
+
* |
|
|
125
|
+
* 3 | export * from './c.module.css';
|
|
126
|
+
* | ^ mapping.generatedOffsets[1]
|
|
127
|
+
*
|
|
128
|
+
* NOTE: Not only the specifier but also the surrounding quotes are included in the mapping.
|
|
129
|
+
*/
|
|
84
130
|
text += `export * from `;
|
|
85
131
|
mapping.sourceOffsets.push(tokenImporter.fromLoc.start.offset - 1);
|
|
86
132
|
mapping.lengths.push(tokenImporter.from.length + 2);
|
|
@@ -88,6 +134,43 @@ function generateNamedExportsDts(localTokens, tokenImporters, options) {
|
|
|
88
134
|
text += `'${tokenImporter.from}';\n`;
|
|
89
135
|
}
|
|
90
136
|
else {
|
|
137
|
+
/**
|
|
138
|
+
* The mapping is created as follows:
|
|
139
|
+
* a.module.css:
|
|
140
|
+
* 1 | @value b_1, b_2 from './b.module.css';
|
|
141
|
+
* | ^ ^ ^ mapping.sourceOffsets[2]
|
|
142
|
+
* | ^ ^ mapping.sourceOffsets[1]
|
|
143
|
+
* | ^ mapping.sourceOffsets[0]
|
|
144
|
+
* |
|
|
145
|
+
* 2 | @value c_1 as aliased_c_1 from './c.module.css';
|
|
146
|
+
* | ^ ^ ^ mapping.sourceOffsets[5]
|
|
147
|
+
* | ^ ^ mapping.sourceOffsets[4]
|
|
148
|
+
* | ^ mapping.sourceOffsets[3]
|
|
149
|
+
* |
|
|
150
|
+
*
|
|
151
|
+
* a.module.css.d.ts:
|
|
152
|
+
* 1 | // @ts-nocheck
|
|
153
|
+
* 2 | export {
|
|
154
|
+
* 3 | b_1,
|
|
155
|
+
* | ^ mapping.generatedOffsets[0]
|
|
156
|
+
* |
|
|
157
|
+
* 4 | b_2,
|
|
158
|
+
* | ^ mapping.generatedOffsets[1]
|
|
159
|
+
* |
|
|
160
|
+
* 5 | } from './b.module.css';
|
|
161
|
+
* | ^ mapping.generatedOffsets[2]
|
|
162
|
+
* |
|
|
163
|
+
* 6 | export {
|
|
164
|
+
* 7 | c_1 as aliased_c_1,
|
|
165
|
+
* | ^ ^ mapping.generatedOffsets[4], linkedCodeMapping.sourceOffsets[0]
|
|
166
|
+
* | ^ mapping.generatedOffsets[3], linkedCodeMapping.generatedOffsets[0]
|
|
167
|
+
* |
|
|
168
|
+
* 8 | } from './c.module.css';
|
|
169
|
+
* | ^ mapping.generatedOffsets[5]
|
|
170
|
+
*
|
|
171
|
+
* NOTE: Not only the specifier but also the surrounding quotes are included in the mapping.
|
|
172
|
+
* NOTE: linkedCodeMapping is only generated for tokens that have a `localName` (i.e., aliased tokens).
|
|
173
|
+
*/
|
|
91
174
|
text += `export {\n`;
|
|
92
175
|
// eslint-disable-next-line no-loop-func
|
|
93
176
|
tokenImporter.values.forEach((value) => {
|
|
@@ -128,29 +211,7 @@ function generateNamedExportsDts(localTokens, tokenImporters, options) {
|
|
|
128
211
|
}
|
|
129
212
|
return { text, mapping, linkedCodeMapping };
|
|
130
213
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Generate a d.ts file with a default export.
|
|
133
|
-
* @example
|
|
134
|
-
* If the CSS module file is:
|
|
135
|
-
* ```css
|
|
136
|
-
* @import './a.module.css';
|
|
137
|
-
* @value local1: string;
|
|
138
|
-
* @value imported1, imported2 as aliasedImported2 from './b.module.css';
|
|
139
|
-
* .local2 { color: red }
|
|
140
|
-
* ```
|
|
141
|
-
* The d.ts file would be:
|
|
142
|
-
* ```ts
|
|
143
|
-
* // @ts-nocheck
|
|
144
|
-
* const styles = {
|
|
145
|
-
* local1: '' as readonly string,
|
|
146
|
-
* local2: '' as readonly string,
|
|
147
|
-
* ...(await import('./a.module.css')).default,
|
|
148
|
-
* imported1: (await import('./b.module.css')).default.imported1,
|
|
149
|
-
* aliasedImported2: (await import('./b.module.css')).default.imported2,
|
|
150
|
-
* };
|
|
151
|
-
* export default styles;
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
214
|
+
/** Generate a d.ts file with a default export. */
|
|
154
215
|
function generateDefaultExportDts(localTokens, tokenImporters) {
|
|
155
216
|
const mapping = { sourceOffsets: [], lengths: [], generatedOffsets: [] };
|
|
156
217
|
const linkedCodeMapping = {
|
|
@@ -164,8 +225,37 @@ function generateDefaultExportDts(localTokens, tokenImporters) {
|
|
|
164
225
|
//
|
|
165
226
|
// If `--skipLibCheck` is false, those errors will be reported by `tsc`. However, these are negligible errors.
|
|
166
227
|
// Therefore, `@ts-nocheck` is added to the generated type definition file.
|
|
167
|
-
let text = `// @ts-nocheck\
|
|
228
|
+
let text = `// @ts-nocheck\n`;
|
|
229
|
+
// This is a workaround to avoid the issue described as a "Drawbacks" in https://github.com/mizdra/css-modules-kit/pull/302.
|
|
230
|
+
// It uses the technique from https://stackoverflow.com/a/55541672 to fall back from `any` to `{}`.
|
|
231
|
+
// However, the import type for an unresolvable specifier becomes a special `any` type called `errorType`.
|
|
232
|
+
// The technique from https://stackoverflow.com/a/55541672 does not work with `errorType`.
|
|
233
|
+
// Therefore, this combines it with the approach from https://github.com/microsoft/TypeScript/issues/62972.
|
|
234
|
+
if (tokenImporters.some((importer) => importer.type === 'import')) {
|
|
235
|
+
text += `function blockErrorType<T>(val: T): [0] extends [(1 & T)] ? {} : T;\n`;
|
|
236
|
+
}
|
|
237
|
+
text += `declare const ${STYLES_EXPORT_NAME} = {\n`;
|
|
168
238
|
for (const token of localTokens) {
|
|
239
|
+
/**
|
|
240
|
+
* The mapping is created as follows:
|
|
241
|
+
* a.module.css:
|
|
242
|
+
* 1 | .a_1 { color: red; }
|
|
243
|
+
* | ^ mapping.sourceOffsets[0]
|
|
244
|
+
* |
|
|
245
|
+
* 2 | .a_2 { color: blue; }
|
|
246
|
+
* | ^ mapping.sourceOffsets[1]
|
|
247
|
+
* |
|
|
248
|
+
*
|
|
249
|
+
* a.module.css.d.ts:
|
|
250
|
+
* 1 | declare const styles = {
|
|
251
|
+
* 2 | a_1: '' as readonly string,
|
|
252
|
+
* | ^ mapping.generatedOffsets[0]
|
|
253
|
+
* |
|
|
254
|
+
* 3 | a_2: '' as readonly string,
|
|
255
|
+
* | ^ mapping.generatedOffsets[1]
|
|
256
|
+
* |
|
|
257
|
+
* 4 | };
|
|
258
|
+
*/
|
|
169
259
|
text += ` `;
|
|
170
260
|
mapping.sourceOffsets.push(token.loc.start.offset);
|
|
171
261
|
mapping.generatedOffsets.push(text.length);
|
|
@@ -174,13 +264,69 @@ function generateDefaultExportDts(localTokens, tokenImporters) {
|
|
|
174
264
|
}
|
|
175
265
|
for (const tokenImporter of tokenImporters) {
|
|
176
266
|
if (tokenImporter.type === 'import') {
|
|
177
|
-
|
|
267
|
+
/**
|
|
268
|
+
* The mapping is created as follows:
|
|
269
|
+
* a.module.css:
|
|
270
|
+
* 1 | @import './b.module.css';
|
|
271
|
+
* | ^ mapping.sourceOffsets[0]
|
|
272
|
+
* |
|
|
273
|
+
* 2 | @import './c.module.css';
|
|
274
|
+
* | ^ mapping.sourceOffsets[1]
|
|
275
|
+
* |
|
|
276
|
+
*
|
|
277
|
+
* a.module.css.d.ts:
|
|
278
|
+
* 1 | declare const styles = {
|
|
279
|
+
* 2 | ...blockErrorType((await import('./b.module.css')).default),
|
|
280
|
+
* | ^ mapping.generatedOffsets[0]
|
|
281
|
+
* |
|
|
282
|
+
* 3 | ...blockErrorType((await import('./c.module.css')).default),
|
|
283
|
+
* | ^ mapping.generatedOffsets[1]
|
|
284
|
+
* |
|
|
285
|
+
* 4 | };
|
|
286
|
+
*
|
|
287
|
+
* NOTE: Not only the specifier but also the surrounding quotes are included in the mapping.
|
|
288
|
+
*/
|
|
289
|
+
text += ` ...blockErrorType((await import(`;
|
|
178
290
|
mapping.sourceOffsets.push(tokenImporter.fromLoc.start.offset - 1);
|
|
179
291
|
mapping.lengths.push(tokenImporter.from.length + 2);
|
|
180
292
|
mapping.generatedOffsets.push(text.length);
|
|
181
|
-
text += `'${tokenImporter.from}')).default,\n`;
|
|
293
|
+
text += `'${tokenImporter.from}')).default),\n`;
|
|
182
294
|
}
|
|
183
295
|
else {
|
|
296
|
+
/**
|
|
297
|
+
* The mapping is created as follows:
|
|
298
|
+
* a.module.css:
|
|
299
|
+
* 1 | @value b_1, b_2 from './b.module.css';
|
|
300
|
+
* | ^ ^ ^ mapping.sourceOffsets[0]
|
|
301
|
+
* | ^ ^ mapping.sourceOffsets[2]
|
|
302
|
+
* | ^ mapping.sourceOffsets[1]
|
|
303
|
+
* |
|
|
304
|
+
* 2 | @value c_1 as aliased_c_1 from './c.module.css';
|
|
305
|
+
* | ^ ^ ^ mapping.sourceOffsets[4]
|
|
306
|
+
* | ^ ^ mapping.sourceOffsets[3]
|
|
307
|
+
* | ^ mapping.sourceOffsets[5]
|
|
308
|
+
* |
|
|
309
|
+
*
|
|
310
|
+
* a.module.css.d.ts:
|
|
311
|
+
* 1 | declare const styles = {
|
|
312
|
+
* 2 | b_1: (await import('./b.module.css')).default.b_1,
|
|
313
|
+
* | ^ ^ ^ linkedCodeMapping.generatedOffsets[0]
|
|
314
|
+
* | ^ ^ mapping.generatedOffsets[1]
|
|
315
|
+
* | ^ mapping.generatedOffsets[0], linkedCodeMapping.sourceOffsets[0]
|
|
316
|
+
* |
|
|
317
|
+
* 3 | b_2: (await import('./b.module.css')).default.b_2,
|
|
318
|
+
* | ^ ^ linkedCodeMapping.generatedOffsets[1]
|
|
319
|
+
* | ^ mapping.generatedOffsets[2], linkedCodeMapping.sourceOffsets[1]
|
|
320
|
+
* |
|
|
321
|
+
* 4 | aliased_c_1: (await import('./c.module.css')).default.c_1,
|
|
322
|
+
* | ^ ^ ^ mapping.generatedOffsets[5], linkedCodeMapping.generatedOffsets[2]
|
|
323
|
+
* | ^ ^ mapping.generatedOffsets[4]
|
|
324
|
+
* | ^ mapping.generatedOffsets[3], linkedCodeMapping.sourceOffsets[2]
|
|
325
|
+
* |
|
|
326
|
+
* 5 | };
|
|
327
|
+
*
|
|
328
|
+
* NOTE: Not only the specifier but also the surrounding quotes are included in the mapping.
|
|
329
|
+
*/
|
|
184
330
|
// eslint-disable-next-line no-loop-func
|
|
185
331
|
tokenImporter.values.forEach((value, i) => {
|
|
186
332
|
const localName = value.localName ?? value.name;
|
|
@@ -198,20 +344,22 @@ function generateDefaultExportDts(localTokens, tokenImporters) {
|
|
|
198
344
|
mapping.generatedOffsets.push(text.length);
|
|
199
345
|
}
|
|
200
346
|
text += `'${tokenImporter.from}')).default.`;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
347
|
+
if ('localName' in value) {
|
|
348
|
+
mapping.sourceOffsets.push(value.loc.start.offset);
|
|
349
|
+
mapping.lengths.push(value.name.length);
|
|
350
|
+
mapping.generatedOffsets.push(text.length);
|
|
351
|
+
}
|
|
204
352
|
linkedCodeMapping.generatedOffsets.push(text.length);
|
|
205
353
|
linkedCodeMapping.generatedLengths.push(value.name.length);
|
|
206
354
|
text += `${value.name},\n`;
|
|
207
355
|
});
|
|
208
356
|
}
|
|
209
357
|
}
|
|
210
|
-
text += `};\nexport default ${
|
|
358
|
+
text += `};\nexport default ${STYLES_EXPORT_NAME};\n`;
|
|
211
359
|
return { text, mapping, linkedCodeMapping };
|
|
212
360
|
}
|
|
213
361
|
function isValidName(name, options) {
|
|
214
|
-
if (!
|
|
362
|
+
if (!isValidAsJSIdentifier(name))
|
|
215
363
|
return false;
|
|
216
364
|
if (name === '__proto__')
|
|
217
365
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dts-generator.js","sourceRoot":"","sources":["../src/dts-generator.ts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AC5D,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/error.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TsConfigFileNotFoundError = exports.SystemError = void 0;
|
|
4
|
-
class SystemError extends Error {
|
|
1
|
+
export class SystemError extends Error {
|
|
5
2
|
code;
|
|
6
3
|
constructor(code, message, cause) {
|
|
7
4
|
super(message, { cause });
|
|
8
5
|
this.code = code;
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
class TsConfigFileNotFoundError extends SystemError {
|
|
8
|
+
export class TsConfigFileNotFoundError extends SystemError {
|
|
13
9
|
constructor() {
|
|
14
10
|
super('TS_CONFIG_NOT_FOUND', 'No tsconfig.json found.');
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
exports.TsConfigFileNotFoundError = TsConfigFileNotFoundError;
|
|
18
13
|
//# sourceMappingURL=error.js.map
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,IAAI,CAAS;IACb,YAAY,IAAY,EAAE,OAAe,EAAE,KAAe;QACxD,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IACxD;QACE,KAAK,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;IAC1D,CAAC;CACF"}
|
package/dist/export-builder.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createExportBuilder = createExportBuilder;
|
|
4
1
|
/**
|
|
5
2
|
* A builder for exported token records of CSS modules.
|
|
6
3
|
*/
|
|
7
4
|
// TODO: Handle same token name from different modules
|
|
8
|
-
function createExportBuilder(host) {
|
|
5
|
+
export function createExportBuilder(host) {
|
|
9
6
|
const cache = new Map();
|
|
10
7
|
function build(cssModule) {
|
|
11
8
|
const cached = cache.get(cssModule.fileName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-builder.js","sourceRoot":"","sources":["../src/export-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"export-builder.js","sourceRoot":"","sources":["../src/export-builder.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,sDAAsD;AACtD,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE9C,SAAS,KAAK,CAAC,SAAoB;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,+CAA+C;QAC/C,mDAAmD;QACnD,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QAEjD,MAAM,MAAM,GAAiB,EAAE,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QAE1F,KAAK,MAAM,aAAa,IAAI,SAAS,CAAC,cAAc,EAAE,CAAC;YACrD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;YAChF,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;gBAAE,SAAS;YAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;YACvC,IAAI,aAAa,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACpC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;YACrD,CAAC;iBAAM,CAAC;gBACN,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;oBACzC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,SAAS,UAAU;QACjB,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC"}
|
package/dist/file.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CSS_MODULE_EXTENSION = void 0;
|
|
7
|
-
exports.isCSSModuleFile = isCSSModuleFile;
|
|
8
|
-
exports.getCssModuleFileName = getCssModuleFileName;
|
|
9
|
-
exports.isComponentFileName = isComponentFileName;
|
|
10
|
-
exports.findComponentFile = findComponentFile;
|
|
11
|
-
exports.findComponentFileSync = findComponentFileSync;
|
|
12
|
-
exports.createMatchesPattern = createMatchesPattern;
|
|
13
|
-
exports.getFileNamesByPattern = getFileNamesByPattern;
|
|
14
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
15
|
-
const path_js_1 = require("./path.js");
|
|
16
|
-
exports.CSS_MODULE_EXTENSION = '.module.css';
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { join, parse } from './path.js';
|
|
3
|
+
export const CSS_MODULE_EXTENSION = '.module.css';
|
|
17
4
|
const COMPONENT_EXTENSIONS = ['.tsx', '.jsx'];
|
|
18
|
-
function isCSSModuleFile(fileName) {
|
|
19
|
-
return fileName.endsWith(
|
|
5
|
+
export function isCSSModuleFile(fileName) {
|
|
6
|
+
return fileName.endsWith(CSS_MODULE_EXTENSION);
|
|
20
7
|
}
|
|
21
|
-
function getCssModuleFileName(tsFileName) {
|
|
22
|
-
const { dir, name } =
|
|
23
|
-
return
|
|
8
|
+
export function getCssModuleFileName(tsFileName) {
|
|
9
|
+
const { dir, name } = parse(tsFileName);
|
|
10
|
+
return join(dir, `${name}${CSS_MODULE_EXTENSION}`);
|
|
24
11
|
}
|
|
25
|
-
function isComponentFileName(fileName) {
|
|
12
|
+
export function isComponentFileName(fileName) {
|
|
26
13
|
// NOTE: Do not check whether it is an upper camel case or not, since lower camel case (e.g. `page.tsx`) is used in Next.js.
|
|
27
14
|
return COMPONENT_EXTENSIONS.some((ext) => fileName.endsWith(ext));
|
|
28
15
|
}
|
|
29
|
-
async function findComponentFile(cssModuleFileName, readFile) {
|
|
30
|
-
const pathWithoutExtension = cssModuleFileName.slice(0, -
|
|
16
|
+
export async function findComponentFile(cssModuleFileName, readFile) {
|
|
17
|
+
const pathWithoutExtension = cssModuleFileName.slice(0, -CSS_MODULE_EXTENSION.length);
|
|
31
18
|
for (const path of COMPONENT_EXTENSIONS.map((ext) => pathWithoutExtension + ext)) {
|
|
32
19
|
try {
|
|
33
20
|
// TODO: Cache the result of readFile
|
|
@@ -41,8 +28,8 @@ async function findComponentFile(cssModuleFileName, readFile) {
|
|
|
41
28
|
}
|
|
42
29
|
return undefined;
|
|
43
30
|
}
|
|
44
|
-
function findComponentFileSync(cssModuleFileName, readFileSync) {
|
|
45
|
-
const pathWithoutExtension = cssModuleFileName.slice(0, -
|
|
31
|
+
export function findComponentFileSync(cssModuleFileName, readFileSync) {
|
|
32
|
+
const pathWithoutExtension = cssModuleFileName.slice(0, -CSS_MODULE_EXTENSION.length);
|
|
46
33
|
for (const path of COMPONENT_EXTENSIONS.map((ext) => pathWithoutExtension + ext)) {
|
|
47
34
|
try {
|
|
48
35
|
// TODO: Cache the result of readFile
|
|
@@ -61,7 +48,7 @@ function findComponentFileSync(cssModuleFileName, readFileSync) {
|
|
|
61
48
|
* @param options
|
|
62
49
|
* @returns
|
|
63
50
|
*/
|
|
64
|
-
function createMatchesPattern(options) {
|
|
51
|
+
export function createMatchesPattern(options) {
|
|
65
52
|
// Setup utilities to check for pattern matches without accessing the file system
|
|
66
53
|
const realpath = (path) => path;
|
|
67
54
|
const getFileSystemEntries = (path) => {
|
|
@@ -71,7 +58,7 @@ function createMatchesPattern(options) {
|
|
|
71
58
|
};
|
|
72
59
|
};
|
|
73
60
|
return (fileName) => {
|
|
74
|
-
const matchedFileNames =
|
|
61
|
+
const matchedFileNames = ts.matchFiles(fileName, [CSS_MODULE_EXTENSION], options.excludes, options.includes, ts.sys.useCaseSensitiveFileNames, '', // `fileName`, `includes`, and `excludes` are absolute paths, so `currentDirectory` is not needed.
|
|
75
62
|
undefined, getFileSystemEntries, realpath);
|
|
76
63
|
return matchedFileNames.length > 0;
|
|
77
64
|
};
|
|
@@ -79,10 +66,10 @@ function createMatchesPattern(options) {
|
|
|
79
66
|
/**
|
|
80
67
|
* Get files matched by the pattern.
|
|
81
68
|
*/
|
|
82
|
-
function getFileNamesByPattern(options) {
|
|
69
|
+
export function getFileNamesByPattern(options) {
|
|
83
70
|
// ref: https://github.com/microsoft/TypeScript/blob/caf1aee269d1660b4d2a8b555c2d602c97cb28d7/src/compiler/commandLineParser.ts#L3929
|
|
84
71
|
// MEMO: `ts.sys.readDirectory` catch errors internally. So we don't need to wrap with try-catch.
|
|
85
72
|
// https://github.com/microsoft/TypeScript/blob/caf1aee269d1660b4d2a8b555c2d602c97cb28d7/src/compiler/sys.ts#L1877-L1879
|
|
86
|
-
return
|
|
73
|
+
return ts.sys.readDirectory(options.basePath, [CSS_MODULE_EXTENSION], options.excludes, options.includes);
|
|
87
74
|
}
|
|
88
75
|
//# sourceMappingURL=file.js.map
|
package/dist/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAClD,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IACrD,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,oBAAoB,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,4HAA4H;IAC5H,OAAO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AM,UAAU,oBAAoB,CAAC,OAAmD;IACtF,iFAAiF;IACjF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC;IACxC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAwB,EAAE;QAClE,OAAO;YACL,KAAK,EAAE,CAAC,IAAI,CAAC;YACb,WAAW,EAAE,EAAE;SAChB,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,QAAgB,EAAE,EAAE;QAC1B,MAAM,gBAAgB,GAAG,EAAE,CAAC,UAAU,CACpC,QAAQ,EACR,CAAC,oBAAoB,CAAC,EACtB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,EAChB,EAAE,CAAC,GAAG,CAAC,yBAAyB,EAChC,EAAE,EAAE,kGAAkG;QACtG,SAAS,EACT,oBAAoB,EACpB,QAAQ,CACT,CAAC;QACF,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAqE;IACzG,qIAAqI;IAErI,iGAAiG;IACjG,wHAAwH;IAExH,OAAO,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5G,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ export { readConfigFile } from './config.js';
|
|
|
3
3
|
export { TsConfigFileNotFoundError, SystemError } from './error.js';
|
|
4
4
|
export { parseCSSModule, type ParseCSSModuleOptions } from './parser/css-module-parser.js';
|
|
5
5
|
export { parseRule } from './parser/rule-parser.js';
|
|
6
|
-
export { type Location, type Position, type CSSModule, type Token, type AtImportTokenImporter, type TokenImporter, type AtValueTokenImporter, type AtValueTokenImporterValue, type Resolver, type MatchesPattern, type ExportBuilder, type DiagnosticSourceFile, type Diagnostic, type DiagnosticWithLocation, type DiagnosticCategory, type DiagnosticPosition, } from './type.js';
|
|
6
|
+
export { type Location, type Position, type CSSModule, type Token, type AtImportTokenImporter, type TokenImporter, type AtValueTokenImporter, type AtValueTokenImporterValue, type Resolver, type MatchesPattern, type ExportBuilder, type ExportRecord, type DiagnosticSourceFile, type Diagnostic, type DiagnosticWithLocation, type DiagnosticCategory, type DiagnosticPosition, } from './type.js';
|
|
7
7
|
export { type GenerateDtsOptions, generateDts, STYLES_EXPORT_NAME } from './dts-generator.js';
|
|
8
8
|
export { createResolver } from './resolver.js';
|
|
9
9
|
export { CSS_MODULE_EXTENSION, getCssModuleFileName, isComponentFileName, isCSSModuleFile, findComponentFile, findComponentFileSync, createMatchesPattern, getFileNamesByPattern, } from './file.js';
|
|
10
|
-
export { checkCSSModule } from './checker.js';
|
|
10
|
+
export { checkCSSModule, type CheckerArgs } from './checker.js';
|
|
11
11
|
export { createExportBuilder } from './export-builder.js';
|
|
12
|
-
export { join, resolve, relative, dirname, basename, parse
|
|
12
|
+
export { join, resolve, relative, dirname, basename, parse } from './path.js';
|
|
13
13
|
export { findUsedTokenNames } from './util.js';
|
|
14
14
|
export { convertDiagnostic, convertDiagnosticWithLocation, convertSystemError } from './diagnostic.js';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;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,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var dts_generator_js_1 = require("./dts-generator.js");
|
|
14
|
-
Object.defineProperty(exports, "generateDts", { enumerable: true, get: function () { return dts_generator_js_1.generateDts; } });
|
|
15
|
-
Object.defineProperty(exports, "STYLES_EXPORT_NAME", { enumerable: true, get: function () { return dts_generator_js_1.STYLES_EXPORT_NAME; } });
|
|
16
|
-
var resolver_js_1 = require("./resolver.js");
|
|
17
|
-
Object.defineProperty(exports, "createResolver", { enumerable: true, get: function () { return resolver_js_1.createResolver; } });
|
|
18
|
-
var file_js_1 = require("./file.js");
|
|
19
|
-
Object.defineProperty(exports, "CSS_MODULE_EXTENSION", { enumerable: true, get: function () { return file_js_1.CSS_MODULE_EXTENSION; } });
|
|
20
|
-
Object.defineProperty(exports, "getCssModuleFileName", { enumerable: true, get: function () { return file_js_1.getCssModuleFileName; } });
|
|
21
|
-
Object.defineProperty(exports, "isComponentFileName", { enumerable: true, get: function () { return file_js_1.isComponentFileName; } });
|
|
22
|
-
Object.defineProperty(exports, "isCSSModuleFile", { enumerable: true, get: function () { return file_js_1.isCSSModuleFile; } });
|
|
23
|
-
Object.defineProperty(exports, "findComponentFile", { enumerable: true, get: function () { return file_js_1.findComponentFile; } });
|
|
24
|
-
Object.defineProperty(exports, "findComponentFileSync", { enumerable: true, get: function () { return file_js_1.findComponentFileSync; } });
|
|
25
|
-
Object.defineProperty(exports, "createMatchesPattern", { enumerable: true, get: function () { return file_js_1.createMatchesPattern; } });
|
|
26
|
-
Object.defineProperty(exports, "getFileNamesByPattern", { enumerable: true, get: function () { return file_js_1.getFileNamesByPattern; } });
|
|
27
|
-
var checker_js_1 = require("./checker.js");
|
|
28
|
-
Object.defineProperty(exports, "checkCSSModule", { enumerable: true, get: function () { return checker_js_1.checkCSSModule; } });
|
|
29
|
-
var export_builder_js_1 = require("./export-builder.js");
|
|
30
|
-
Object.defineProperty(exports, "createExportBuilder", { enumerable: true, get: function () { return export_builder_js_1.createExportBuilder; } });
|
|
31
|
-
var path_js_1 = require("./path.js");
|
|
32
|
-
Object.defineProperty(exports, "join", { enumerable: true, get: function () { return path_js_1.join; } });
|
|
33
|
-
Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return path_js_1.resolve; } });
|
|
34
|
-
Object.defineProperty(exports, "relative", { enumerable: true, get: function () { return path_js_1.relative; } });
|
|
35
|
-
Object.defineProperty(exports, "dirname", { enumerable: true, get: function () { return path_js_1.dirname; } });
|
|
36
|
-
Object.defineProperty(exports, "basename", { enumerable: true, get: function () { return path_js_1.basename; } });
|
|
37
|
-
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return path_js_1.parse; } });
|
|
38
|
-
Object.defineProperty(exports, "isAbsolute", { enumerable: true, get: function () { return path_js_1.isAbsolute; } });
|
|
39
|
-
var util_js_1 = require("./util.js");
|
|
40
|
-
Object.defineProperty(exports, "findUsedTokenNames", { enumerable: true, get: function () { return util_js_1.findUsedTokenNames; } });
|
|
41
|
-
var diagnostic_js_1 = require("./diagnostic.js");
|
|
42
|
-
Object.defineProperty(exports, "convertDiagnostic", { enumerable: true, get: function () { return diagnostic_js_1.convertDiagnostic; } });
|
|
43
|
-
Object.defineProperty(exports, "convertDiagnosticWithLocation", { enumerable: true, get: function () { return diagnostic_js_1.convertDiagnosticWithLocation; } });
|
|
44
|
-
Object.defineProperty(exports, "convertSystemError", { enumerable: true, get: function () { return diagnostic_js_1.convertSystemError; } });
|
|
1
|
+
export { readConfigFile } from './config.js';
|
|
2
|
+
export { TsConfigFileNotFoundError, SystemError } from './error.js';
|
|
3
|
+
export { parseCSSModule } from './parser/css-module-parser.js';
|
|
4
|
+
export { parseRule } from './parser/rule-parser.js';
|
|
5
|
+
export { generateDts, STYLES_EXPORT_NAME } from './dts-generator.js';
|
|
6
|
+
export { createResolver } from './resolver.js';
|
|
7
|
+
export { CSS_MODULE_EXTENSION, getCssModuleFileName, isComponentFileName, isCSSModuleFile, findComponentFile, findComponentFileSync, createMatchesPattern, getFileNamesByPattern, } from './file.js';
|
|
8
|
+
export { checkCSSModule } from './checker.js';
|
|
9
|
+
export { createExportBuilder } from './export-builder.js';
|
|
10
|
+
export { join, resolve, relative, dirname, basename, parse } from './path.js';
|
|
11
|
+
export { findUsedTokenNames } from './util.js';
|
|
12
|
+
export { convertDiagnostic, convertDiagnosticWithLocation, convertSystemError } from './diagnostic.js';
|
|
45
13
|
//# sourceMappingURL=index.js.map
|