Skip to content

Commit

Permalink
fix: allow bundlers to resolve common packages
Browse files Browse the repository at this point in the history
for stylelint/vscode-stylelint
  • Loading branch information
adalinesimonian committed Sep 29, 2021
1 parent 0bca5a4 commit ba1d4a6
Show file tree
Hide file tree
Showing 7 changed files with 6,325 additions and 6 deletions.
3 changes: 2 additions & 1 deletion get-syntax.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
const path = require("path");
const reSyntaxCSS = /^(?:post)?css$/i;
const { resolvePackage } = require("./resolve-package");

function cssSyntax () {
return {
Expand Down Expand Up @@ -28,7 +29,7 @@ function requireSyntax (syntax) {
} else {
syntax = syntax.toLowerCase().replace(/^(?:postcss-)?(\w+)/i, "postcss-$1");
}
return normalize(require(syntax));
return normalize(resolvePackage(syntax));
}

function getSyntax (lang, opts) {
Expand Down
5 changes: 3 additions & 2 deletions load-syntax.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
const getSyntax = require("./get-syntax");
const { resolvePackage } = require("./resolve-package");
const cache = {};

function loadSyntax (opts, id) {
Expand All @@ -8,10 +9,10 @@ function loadSyntax (opts, id) {
let syntax = cache[modulePath];
if (!syntax) {
syntax = {
parse: require(modulePath),
parse: resolvePackage(modulePath),
};
try {
syntax.stringify = require(id + "/template-stringify");
syntax.stringify = resolvePackage(id + "/template-stringify");
} catch (ex) {
syntax.stringify = cssSyntax.stringify;
}
Expand Down
Loading

0 comments on commit ba1d4a6

Please sign in to comment.