Skip to content

Commit

Permalink
fix; module name path
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jan 2, 2024
1 parent d7920a6 commit 6ff277c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,25 @@ export const generateCode = async (config: TextlintConfigDescriptor) => {
}
];
*/
const normalizeModuleName = (moduleName: string) => {
// window path -> posix path
return moduleName.replace(/\\/g, "/");
};
const createImportCode = (a: TextlintConfigRule, index: number) => {
if (a.type === "Rule") {
return `import __rule${index} from "${a.moduleName}";`;
return `import __rule${index} from "${normalizeModuleName(a.moduleName)}";`;
} else if (a.type === "RuleInPreset") {
return `import __rulePreset${index} from "${a.moduleName}";
return `import __rulePreset${index} from "${normalizeModuleName(a.moduleName)}";
const __rule${index} = __rulePreset${index}.rules["${a.ruleKey}"];`;
} else {
throw new Error("Unknown type");
}
};
const createFilterRuleImportCode = (a: TextlintConfigFilterRule, index: number) => {
return `import __filterRule${index} from "${a.moduleName}";`;
return `import __filterRule${index} from "${normalizeModuleName(a.moduleName)}";`;
};
const createPluginImportCode = (a: TextlintConfigPlugin, index: number) => {
return `import __plugin${index} from "${a.moduleName}";`;
return `import __plugin${index} from "${normalizeModuleName(a.moduleName)}";`;
};
return `// Generated webworker code by textlint-script-compiler
import { TextlintKernel } from "@textlint/kernel";
Expand Down
2 changes: 0 additions & 2 deletions packages/@textlint/script-compiler/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ export const compile = async (options: compileOptions) => {
config: rawConfig
}
});
console.log("DEBUG: inputFilePath");
console.log(fs.readFileSync(inputFilePath, "utf-8"));
webpack([config], (error: undefined | (Error & { details?: string }), stats?) => {
if (error) {
console.error(error.stack || error);
Expand Down

0 comments on commit 6ff277c

Please sign in to comment.