Skip to content

Commit

Permalink
a few more const => var
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Jenkinson committed Jul 17, 2020
1 parent 8307635 commit 6f0af22
Show file tree
Hide file tree
Showing 6 changed files with 603 additions and 672 deletions.
1,253 changes: 592 additions & 661 deletions __tests__/__snapshots__/index.test.ts.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __tests__/fixtures/modules/composed.css.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const css: string;
export var css: string;
interface ModulesExports {"primary":"#BF4040","composition":"composed_composition composition2_compositioned"}
interface ModulesExports {inject:()=>void}
declare const modules_2a102cc5: ModulesExports;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/fixtures/modules/style.css.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const css: string;
export var css: string;
interface ModulesExports {"primary":"#BF4040","secondary":"#1F4F7F","module":"style_module","module2":"style_module2 composed_composition composition2_compositioned"}
interface ModulesExports {inject:()=>void}
declare const modules_5a199c00: ModulesExports;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/fixtures/modules/subdir/composition2.css.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const css: string;
export var css: string;
interface ModulesExports {"compositioned":"composition2_compositioned"}
interface ModulesExports {inject:()=>void}
declare const modules_354770d7: ModulesExports;
Expand Down
8 changes: 4 additions & 4 deletions __tests__/fixtures/named-exports/style.css.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const css: string;
export const valid: "style_valid";
export const _new: "style_new";
export const _css: "style_css";
export var css: string;
export var valid: "style_valid";
export var _new: "style_new";
export var _css: "style_css";
interface ModulesExports {"valid":"style_valid","new":"style_new","css":"style_css"}
declare const modules_5a199c00: ModulesExports;
export default modules_5a199c00;
8 changes: 4 additions & 4 deletions src/loaders/postcss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ const loader: Loader<PostCSSLoaderOptions> = {
const saferId = (id: string): string => safeId(id, path.basename(this.id));
const modulesVarName = saferId("modules");

const output = [`export const ${cssVarName} = ${JSON.stringify(res.css)};`];
const dts = [`export const ${cssVarName}: string;`];
const output = [`export var ${cssVarName} = ${JSON.stringify(res.css)};`];
const dts = [`export var ${cssVarName}: string;`];

if (options.namedExports) {
const getClassName =
Expand All @@ -141,8 +141,8 @@ const loader: Loader<PostCSSLoaderOptions> = {
this.warn(`Exported \`${name}\` as \`${newName}\` in ${humanlizePath(this.id)}`);

const fmt = JSON.stringify(modulesExports[name]);
output.push(`export const ${newName} = ${fmt};`);
if (options.dts) dts.push(`export const ${newName}: ${fmt};`);
output.push(`export var ${newName} = ${fmt};`);
if (options.dts) dts.push(`export var ${newName}: ${fmt};`);
}
}

Expand Down

0 comments on commit 6f0af22

Please sign in to comment.