Skip to content

Commit

Permalink
feat!(ts-plugin): Use faux ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdra committed Dec 11, 2024
1 parent a56ef87 commit 6440b3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ts-honey-css-modules-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ts-honey-css-modules-plugin",
"description": "TypeScript Language Service Plugin for CSS Modules",
"version": "0.0.0",
"type": "module",
"type": "commonjs",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import quickstartModule = require('@volar/typescript/lib/quickstart/createAsyncLanguageServicePlugin.js');
import path = require('path');
import ts = require('typescript/lib/tsserverlibrary');
import path from 'node:path';
import { createAsyncLanguageServicePlugin } from '@volar/typescript/lib/quickstart/createAsyncLanguageServicePlugin.js';
import ts from 'typescript/lib/tsserverlibrary.js';

const init = quickstartModule.createAsyncLanguageServicePlugin(['.css'], ts.ScriptKind.TS, async (ts, info) => {
const init = createAsyncLanguageServicePlugin(['.css'], ts.ScriptKind.TS, async (ts, info) => {
if (info.project.projectKind !== ts.server.ProjectKind.Configured) {
info.project.projectService.logger.info(`[ts-honey-css-modules-plugin] tsconfig.json not found`);
return {
Expand All @@ -16,6 +15,7 @@ const init = quickstartModule.createAsyncLanguageServicePlugin(['.css'], ts.Scri
const resolvedConfig = resolveConfig(info.config);
const resolver = createResolver(resolvedConfig.alias, resolvedConfig.cwd);
const isExternalFile = (filename: string) =>
// eslint-disable-next-line n/no-unsupported-features/node-builtins
!path.matchesGlob(
filename,
path.join(cwd, resolvedConfig.pattern), // `pattern` is 'src/**/*.module.css', so convert it to '/project/src/**/*.module.css'
Expand Down Expand Up @@ -49,4 +49,4 @@ const init = quickstartModule.createAsyncLanguageServicePlugin(['.css'], ts.Scri
};
});

export = init;
export default init;
1 change: 1 addition & 0 deletions packages/ts-honey-css-modules-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"module": "NodeNext" /* Specify what module code is generated. */,
// If --module=NodeNext, --moduleResolution=NodeNext can be omitted. However, it is set just in case.
"moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */,
"verbatimModuleSyntax": false /* Preserve the full syntactic structure of the module input file. */,

"paths": {
"honey-css-modules": ["../honey-css-modules/src/index.ts"]
Expand Down

0 comments on commit 6440b3d

Please sign in to comment.