clarusjs 0.15.0 → 0.16.0
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/check/generate.js +19 -6
- package/dist/cli/check.d.ts +6 -2
- package/dist/cli/check.js +37 -13
- package/dist/cli/index.js +4 -1
- package/dist/cli/mapper.js +6 -1
- package/dist/cli/project.d.ts +2 -0
- package/dist/compiler/components.d.ts +29 -0
- package/dist/compiler/components.js +18 -0
- package/dist/compiler/element-attrs.d.ts +7 -0
- package/dist/compiler/element-attrs.js +32 -0
- package/dist/compiler/emit-client.js +6 -1
- package/dist/compiler/emit-server.js +1 -1
- package/dist/compiler/html-expr.js +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/index.js +94 -7
- package/dist/compiler/ir.d.ts +4 -0
- package/dist/compiler/ir.js +3 -0
- package/dist/compiler/lint.d.ts +26 -2
- package/dist/compiler/lint.js +64 -4
- package/dist/compiler/parse.d.ts +17 -0
- package/dist/compiler/parse.js +15 -0
- package/dist/runtime/attrs.d.ts +1 -1
- package/dist/runtime/attrs.js +8 -5
- package/dist/runtime/dom.d.ts +8 -2
- package/dist/runtime/dom.js +36 -5
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/loader.js +21 -1
- package/dist/vite/build.d.ts +9 -2
- package/dist/vite/build.js +20 -5
- package/dist/vite/libraries.d.ts +32 -0
- package/dist/vite/libraries.js +77 -0
- package/dist/vite/plugin.d.ts +5 -1
- package/dist/vite/plugin.js +13 -19
- package/package.json +1 -1
package/dist/vite/plugin.js
CHANGED
|
@@ -17,14 +17,14 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
17
17
|
};
|
|
18
18
|
import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, watch as watchFs, writeFileSync } from 'node:fs';
|
|
19
19
|
import { brotliCompressSync, constants as zlibConstants, gzipSync } from 'node:zlib';
|
|
20
|
-
import { createRequire } from 'node:module';
|
|
21
20
|
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
22
21
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
23
22
|
import { isRunnableDevEnvironment, normalizePath } from 'vite';
|
|
24
23
|
import { compile, scopeId, ClarusError } from '../compiler/index.js';
|
|
25
24
|
import { parse } from '../compiler/parse.js';
|
|
26
|
-
import { COMPONENT_DIRS, componentIndex } from '../compiler/components.js';
|
|
27
|
-
import {
|
|
25
|
+
import { autoImport, COMPONENT_DIRS, componentIndex } from '../compiler/components.js';
|
|
26
|
+
import { componentNames } from './libraries.js';
|
|
27
|
+
import { findClarusFiles, packageOf as packageOfFile, prerender, reachableComponents, resolvePackage, routeToFile } from './build.js';
|
|
28
28
|
export { packageOf } from './build.js';
|
|
29
29
|
export { gitDates } from './sitemap.js';
|
|
30
30
|
import { writeManifest } from './manifest.js';
|
|
@@ -65,18 +65,15 @@ const STYLES_FILE = '.clarusjs/styles.css';
|
|
|
65
65
|
const scopeFor = (root, file) => scopeId(relative(root, file).split(sep).join('/'));
|
|
66
66
|
function pageGraph(root, files, aliases = []) {
|
|
67
67
|
const deps = new Map();
|
|
68
|
-
const
|
|
69
|
-
const packageFile = (spec) => { try {
|
|
70
|
-
return realpathSync(require.resolve(spec.replace(/\?.*$/, '')));
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return undefined;
|
|
74
|
-
} };
|
|
68
|
+
const names = files.names(root);
|
|
75
69
|
const read = (file) => {
|
|
76
70
|
if (!deps.has(file)) {
|
|
77
71
|
let parsed;
|
|
78
72
|
try {
|
|
79
|
-
|
|
73
|
+
const text = files.read(file, root);
|
|
74
|
+
parsed = parse(text, file);
|
|
75
|
+
if (names)
|
|
76
|
+
autoImport(parsed, names, file, text);
|
|
80
77
|
}
|
|
81
78
|
catch {
|
|
82
79
|
parsed = null;
|
|
@@ -85,7 +82,8 @@ function pageGraph(root, files, aliases = []) {
|
|
|
85
82
|
const path = from.replace(/\?.*$/, '');
|
|
86
83
|
return path.startsWith('/') ? resolve(root, `.${path}`) : resolve(dirname(file), path);
|
|
87
84
|
};
|
|
88
|
-
const
|
|
85
|
+
const packageFile = (spec) => { const found = resolvePackage(root, file, spec); return found && realpathSync(found); };
|
|
86
|
+
const bare = (from) => resolveAlias(from.replace(/\?.*$/, ''), aliases) ?? packageFile(from.replace(/\?.*$/, ''));
|
|
89
87
|
deps.set(file, {
|
|
90
88
|
css: parsed?.cssImports.map((c) => (/^[./]/.test(c.from) ? near(c.from) : bare(c.from))).filter((f) => !!f) ?? [],
|
|
91
89
|
components: parsed?.imports.map((imp) => (/^[./]/.test(imp.from) ? near(imp.from) : bare(imp.from))).filter((f) => !!f) ?? [],
|
|
@@ -215,13 +213,8 @@ export default function clarusjs(options = {}) {
|
|
|
215
213
|
find: (dir) => findClarusFiles(dir, extensions).filter((f) => f.endsWith('.tscl') || f.includes(`${sep}src${sep}pages${sep}`)),
|
|
216
214
|
pages: (root) => files.find(resolve(root, 'src/pages')).filter((f) => isPageFile(f.split(sep).join('/'))),
|
|
217
215
|
layouts: (file, root) => layoutsFor(root, file, options.layouts ?? []),
|
|
218
|
-
names: (root) =>
|
|
219
|
-
|
|
220
|
-
return undefined;
|
|
221
|
-
const found = findClarusFiles(resolve(root, 'src'), ['.tscl']).map((f) => relative(root, f).split(sep).join('/'));
|
|
222
|
-
return componentIndex(found, options.components?.dirs ?? COMPONENT_DIRS).names;
|
|
223
|
-
},
|
|
224
|
-
components: (appRoot) => reachableComponents(appRoot, [...files.find(resolve(appRoot, 'src')), ...extra(appRoot).filter((f) => existsSync(f))], (file) => files.read(file, appRoot), extensions, aliases),
|
|
216
|
+
names: (root) => componentNames(root, options.components),
|
|
217
|
+
components: (appRoot) => reachableComponents(appRoot, [...files.find(resolve(appRoot, 'src')), ...extra(appRoot).filter((f) => existsSync(f))], (file) => files.read(file, appRoot), extensions, aliases, files.names(appRoot)),
|
|
225
218
|
read: (file, appRoot) => {
|
|
226
219
|
const code = readFileSync(file, 'utf8');
|
|
227
220
|
const src = sources.find((x) => file.endsWith(x.extension));
|
|
@@ -359,6 +352,7 @@ export default function clarusjs(options = {}) {
|
|
|
359
352
|
config.logger.warn(`clarusjs: ${file} isn't imported automatically: its name isn't kebab-case (rename it, or @import it)`);
|
|
360
353
|
}
|
|
361
354
|
}
|
|
355
|
+
componentNames(root, options.components);
|
|
362
356
|
},
|
|
363
357
|
async buildApp(builder) {
|
|
364
358
|
const { client, ssr } = builder.environments;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clarusjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Clear, compiled views: templates compiled to server HTML, with JavaScript only for interactive islands. SSR, SSG and CSR from one component model, built on Vite.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|