@marko/language-tools 2.1.11 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +33 -6
- package/dist/index.mjs +33 -6
- package/dist/processors/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1533,14 +1533,17 @@ var import_fs = __toESM(require("fs"));
|
|
|
1533
1533
|
var import_path = __toESM(require("path"));
|
|
1534
1534
|
function getComponentFilename(from) {
|
|
1535
1535
|
const dir = import_path.default.dirname(from);
|
|
1536
|
-
|
|
1536
|
+
let nameNoExt = import_path.default.basename(from, ".marko");
|
|
1537
|
+
if (nameNoExt.endsWith(".d")) {
|
|
1538
|
+
nameNoExt = nameNoExt.slice(0, -2);
|
|
1539
|
+
}
|
|
1537
1540
|
const isEntry = nameNoExt === "index";
|
|
1538
|
-
const
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1541
|
-
|
|
1541
|
+
const fileMatch = `(${nameNoExt.replace(/\./g, "\\.")}\\.${isEntry ? "|" : ""})`;
|
|
1542
|
+
const componentMatch = new RegExp(
|
|
1543
|
+
`^${fileMatch}component(-browser)?\\.\\w+$`
|
|
1544
|
+
);
|
|
1542
1545
|
for (const entry of tryReaddirSync(dir)) {
|
|
1543
|
-
if (
|
|
1546
|
+
if (componentMatch.test(entry)) {
|
|
1544
1547
|
return import_path.default.join(dir, entry);
|
|
1545
1548
|
}
|
|
1546
1549
|
}
|
|
@@ -3165,6 +3168,8 @@ function getExt(fileName) {
|
|
|
3165
3168
|
|
|
3166
3169
|
// src/processors/marko.ts
|
|
3167
3170
|
var import_path3 = __toESM(require("path"));
|
|
3171
|
+
var isRemapExtensionReg = /\.ts$/;
|
|
3172
|
+
var skipRemapExtensionsReg = /\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/;
|
|
3168
3173
|
var marko_default = {
|
|
3169
3174
|
extension: ".marko",
|
|
3170
3175
|
create({ ts, host, configFile }) {
|
|
@@ -3175,6 +3180,7 @@ var marko_default = {
|
|
|
3175
3180
|
runtimeTypes.internalTypesFile,
|
|
3176
3181
|
runtimeTypes.markoTypesFile
|
|
3177
3182
|
];
|
|
3183
|
+
const getJSFileIfTSExists = (source, importer) => host.fileExists(import_path3.default.join(importer, "..", `${source}.ts`)) && `${source}.js`;
|
|
3178
3184
|
const compileConfig = {
|
|
3179
3185
|
output: "source",
|
|
3180
3186
|
stripTypes: true,
|
|
@@ -3183,6 +3189,27 @@ var marko_default = {
|
|
|
3183
3189
|
babelrc: false,
|
|
3184
3190
|
configFile: false,
|
|
3185
3191
|
browserslistConfigFile: false,
|
|
3192
|
+
plugins: [
|
|
3193
|
+
{
|
|
3194
|
+
visitor: {
|
|
3195
|
+
// Find all relative imports in Marko template
|
|
3196
|
+
// if they would map to a `.ts` file, then we convert it to a `.js` file for the output.
|
|
3197
|
+
"ImportDeclaration|ExportNamedDeclaration"(decl) {
|
|
3198
|
+
var _a;
|
|
3199
|
+
const { node } = decl;
|
|
3200
|
+
const value = (_a = node.source) == null ? void 0 : _a.value;
|
|
3201
|
+
const importKind = "importKind" in node ? node.importKind : void 0;
|
|
3202
|
+
if ((value == null ? void 0 : value[0]) === "." && (!importKind || importKind === "value") && !skipRemapExtensionsReg.test(value)) {
|
|
3203
|
+
const filename = decl.hub.file.opts.filename;
|
|
3204
|
+
const remap = isRemapExtensionReg.test(value) ? `${value.slice(0, -2)}js` : getJSFileIfTSExists(value, filename) || getJSFileIfTSExists(`${value}/index`, filename);
|
|
3205
|
+
if (remap) {
|
|
3206
|
+
node.source.value = remap;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
],
|
|
3186
3213
|
caller: {
|
|
3187
3214
|
name: "@marko/type-check",
|
|
3188
3215
|
supportsStaticESM: true,
|
package/dist/index.mjs
CHANGED
|
@@ -1501,14 +1501,17 @@ import fs from "fs";
|
|
|
1501
1501
|
import path from "path";
|
|
1502
1502
|
function getComponentFilename(from) {
|
|
1503
1503
|
const dir = path.dirname(from);
|
|
1504
|
-
|
|
1504
|
+
let nameNoExt = path.basename(from, ".marko");
|
|
1505
|
+
if (nameNoExt.endsWith(".d")) {
|
|
1506
|
+
nameNoExt = nameNoExt.slice(0, -2);
|
|
1507
|
+
}
|
|
1505
1508
|
const isEntry = nameNoExt === "index";
|
|
1506
|
-
const
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1509
|
+
const fileMatch = `(${nameNoExt.replace(/\./g, "\\.")}\\.${isEntry ? "|" : ""})`;
|
|
1510
|
+
const componentMatch = new RegExp(
|
|
1511
|
+
`^${fileMatch}component(-browser)?\\.\\w+$`
|
|
1512
|
+
);
|
|
1510
1513
|
for (const entry of tryReaddirSync(dir)) {
|
|
1511
|
-
if (
|
|
1514
|
+
if (componentMatch.test(entry)) {
|
|
1512
1515
|
return path.join(dir, entry);
|
|
1513
1516
|
}
|
|
1514
1517
|
}
|
|
@@ -3133,6 +3136,8 @@ function getExt(fileName) {
|
|
|
3133
3136
|
|
|
3134
3137
|
// src/processors/marko.ts
|
|
3135
3138
|
import path3 from "path";
|
|
3139
|
+
var isRemapExtensionReg = /\.ts$/;
|
|
3140
|
+
var skipRemapExtensionsReg = /\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/;
|
|
3136
3141
|
var marko_default = {
|
|
3137
3142
|
extension: ".marko",
|
|
3138
3143
|
create({ ts, host, configFile }) {
|
|
@@ -3143,6 +3148,7 @@ var marko_default = {
|
|
|
3143
3148
|
runtimeTypes.internalTypesFile,
|
|
3144
3149
|
runtimeTypes.markoTypesFile
|
|
3145
3150
|
];
|
|
3151
|
+
const getJSFileIfTSExists = (source, importer) => host.fileExists(path3.join(importer, "..", `${source}.ts`)) && `${source}.js`;
|
|
3146
3152
|
const compileConfig = {
|
|
3147
3153
|
output: "source",
|
|
3148
3154
|
stripTypes: true,
|
|
@@ -3151,6 +3157,27 @@ var marko_default = {
|
|
|
3151
3157
|
babelrc: false,
|
|
3152
3158
|
configFile: false,
|
|
3153
3159
|
browserslistConfigFile: false,
|
|
3160
|
+
plugins: [
|
|
3161
|
+
{
|
|
3162
|
+
visitor: {
|
|
3163
|
+
// Find all relative imports in Marko template
|
|
3164
|
+
// if they would map to a `.ts` file, then we convert it to a `.js` file for the output.
|
|
3165
|
+
"ImportDeclaration|ExportNamedDeclaration"(decl) {
|
|
3166
|
+
var _a;
|
|
3167
|
+
const { node } = decl;
|
|
3168
|
+
const value = (_a = node.source) == null ? void 0 : _a.value;
|
|
3169
|
+
const importKind = "importKind" in node ? node.importKind : void 0;
|
|
3170
|
+
if ((value == null ? void 0 : value[0]) === "." && (!importKind || importKind === "value") && !skipRemapExtensionsReg.test(value)) {
|
|
3171
|
+
const filename = decl.hub.file.opts.filename;
|
|
3172
|
+
const remap = isRemapExtensionReg.test(value) ? `${value.slice(0, -2)}js` : getJSFileIfTSExists(value, filename) || getJSFileIfTSExists(`${value}/index`, filename);
|
|
3173
|
+
if (remap) {
|
|
3174
|
+
node.source.value = remap;
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
],
|
|
3154
3181
|
caller: {
|
|
3155
3182
|
name: "@marko/type-check",
|
|
3156
3183
|
supportsStaticESM: true,
|
|
@@ -32,5 +32,5 @@ export interface PrintContext {
|
|
|
32
32
|
formatSettings: Required<ts.FormatCodeSettings>;
|
|
33
33
|
}
|
|
34
34
|
export declare const extensions: `.${string}`[];
|
|
35
|
-
export declare function create(options:
|
|
35
|
+
export declare function create(options: CreateProcessorOptions): Record<`.${string}`, Processor>;
|
|
36
36
|
export declare function has(fileName: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@marko/compiler": "^5.28.4"
|