Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": ["./custom-changelog-github.mts", { "repo": "mizdra/css-modules-kit" }],
"changelog": ["./custom-changelog-github.ts", { "repo": "mizdra/css-modules-kit" }],
"commit": false,
"fixed": [],
"linked": [],
Expand Down
5 changes: 5 additions & 0 deletions .changeset/major-friends-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@css-modules-kit/ts-plugin': minor
---

chore: migrate modules other than entry points from CJS to ESM
9 changes: 9 additions & 0 deletions .changeset/sweet-tools-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@css-modules-kit/stylelint-plugin': minor
'@css-modules-kit/eslint-plugin': minor
'@css-modules-kit/codegen': minor
'css-modules-kit-vscode': minor
'@css-modules-kit/core': minor
---

chore: migrate from CJS to ESM
7 changes: 5 additions & 2 deletions .vscode-test.cjs → .vscode-test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
const { defineConfig } = require('@vscode/test-cli');
import { defineConfig } from '@vscode/test-cli';

const baseConfig = /** @type {Parameters<typeof defineConfig>[0]} */ ({
extensionDevelopmentPath: 'packages/vscode',
version: process.env.VSCODE_VERSION ?? 'stable',
mocha: {
timeout: 30_000,
// If the test file is ESM, importing 'vscode' can cause a deadlock.
// ref: https://github.com/microsoft/vscode-test-cli/issues/77#issuecomment-3696907905
// Therefore, we transpile with tsx to CJS before executing.
require: ['tsx/cjs', './scripts/vscode-test-setup.ts'],
},
download: {
timeout: 60_000,
},
});

module.exports = defineConfig([
export default defineConfig([
{
...baseConfig,
label: 'open-css-file',
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

File renamed without changes.
4 changes: 2 additions & 2 deletions packages/codegen/e2e-test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import dedent from 'dedent';
import { expect, test } from 'vitest';
import { createIFF } from '../src/test/fixture.js';

const binPath = join(__dirname, '../bin/cmk.mjs');
const tscPath = join(__dirname, '../../../node_modules/typescript/bin/tsc');
const binPath = join(import.meta.dirname, '../bin/cmk.js');
const tscPath = join(import.meta.dirname, '../../../node_modules/typescript/bin/tsc');

test('generates .d.ts', async () => {
const iff = await createIFF({
Expand Down
4 changes: 2 additions & 2 deletions packages/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@css-modules-kit/codegen",
"description": "A tool for generating `*.d.ts` files for `*.module.css`.",
"version": "0.7.0",
"type": "commonjs",
"type": "module",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -23,7 +23,7 @@
"registry": "https://registry.npmjs.org/"
},
"bin": {
"cmk": "bin/cmk.mjs"
"cmk": "bin/cmk.js"
},
"keywords": [
"css-modules",
Expand Down
2 changes: 1 addition & 1 deletion packages/codegen/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseArgs } from 'node:util';
import { resolve } from '@css-modules-kit/core';
import packageJson from '../package.json';
import packageJson from '../package.json' with { type: 'json' };
import { ParseCLIArgsError } from './error.js';

const helpText = `
Expand Down
2 changes: 1 addition & 1 deletion packages/codegen/src/logger/formatter.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dedent from 'dedent';
import ts from 'typescript';
import { describe, expect, test } from 'vitest';
import { formatDiagnostics, formatTime } from './formatter';
import { formatDiagnostics, formatTime } from './formatter.js';

describe('formatDiagnostics', () => {
const file = ts.createSourceFile(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@css-modules-kit/core",
"description": "The core of css-modules-kit",
"version": "0.7.0",
"type": "commonjs",
"type": "module",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@css-modules-kit/eslint-plugin",
"description": "A eslint plugin for CSS Modules",
"version": "0.3.1",
"type": "commonjs",
"type": "module",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ESLint } from 'eslint';
import packageJson from '../package.json';
import packageJson from '../package.json' with { type: 'json' };
import { noMissingComponentFile } from './rules/no-missing-component-file.js';
import { noUnusedClassNames } from './rules/no-unused-class-names.js';

Expand Down Expand Up @@ -60,4 +60,4 @@ const plugin = {
} satisfies ESLint.Plugin;
plugin.configs.recommended.plugins['css-modules-kit'] = plugin;

export = plugin;
export default plugin;
2 changes: 1 addition & 1 deletion packages/stylelint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@css-modules-kit/stylelint-plugin",
"description": "A stylelint plugin for CSS Modules",
"version": "0.4.1",
"type": "commonjs",
"type": "module",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { noMissingComponentFile } from './rules/no-missing-component-file.js';
import { noUnusedClassNames } from './rules/no-unused-class-names.js';

export = [noUnusedClassNames, noMissingComponentFile];
export default [noUnusedClassNames, noMissingComponentFile];
2 changes: 1 addition & 1 deletion packages/stylelint-plugin/src/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ const recommendedConfig: Config = {
},
};

export = recommendedConfig;
export default recommendedConfig;
2 changes: 1 addition & 1 deletion packages/ts-plugin/e2e-test/test-util/tsserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function launchTsserver(): Tsserver {
'--globalPlugins',
'@css-modules-kit/ts-plugin',
'--pluginProbeLocations',
__dirname,
import.meta.dirname,
],
[],
);
Expand Down
8 changes: 4 additions & 4 deletions packages/ts-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@css-modules-kit/ts-plugin",
"description": "A TypeScript Language Service Plugin for CSS Modules",
"version": "0.7.0",
"type": "commonjs",
"type": "module",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -12,7 +12,7 @@
"author": "mizdra <pp.mizdra@gmail.com>",
"license": "MIT",
"private": false,
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"scripts": {
"build": "tsc -b tsconfig.build.json"
},
Expand All @@ -25,8 +25,8 @@
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"./type": {
"types": "./dist/type.d.ts",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "CSS Modules Kit",
"description": "The VS Code extension for CSS Modules",
"version": "0.4.0",
"type": "commonjs",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/mizdra/css-modules-kit.git",
Expand Down
12 changes: 6 additions & 6 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"composite": true
},
"references": [
{ "path": "packages/core/tsconfig.build.json" },
{ "path": "packages/codegen/tsconfig.build.json" },
{ "path": "packages/ts-plugin/tsconfig.build.json" },
{ "path": "packages/vscode/tsconfig.build.json" },
{ "path": "packages/stylelint-plugin/tsconfig.build.json" },
{ "path": "packages/eslint-plugin/tsconfig.build.json" }
{ "path": "./packages/core/tsconfig.build.json" },
{ "path": "./packages/codegen/tsconfig.build.json" },
{ "path": "./packages/ts-plugin/tsconfig.build.json" },
{ "path": "./packages/vscode/tsconfig.build.json" },
{ "path": "./packages/stylelint-plugin/tsconfig.build.json" },
{ "path": "./packages/eslint-plugin/tsconfig.build.json" }
]
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./tsconfig.base.json",
"include": ["**/*", ".changeset/custom-changelog-github.mts"],
"include": ["**/*", ".changeset/custom-changelog-github.ts"],
"exclude": ["node_modules", "**/dist", "examples"],
"compilerOptions": {
"target": "ES2022",
Expand All @@ -9,5 +9,5 @@

"noEmit": true
},
"references": [{ "path": "tsconfig.build.json" }]
"references": [{ "path": "./tsconfig.build.json" }]
}