@effectweb/compiler 0.3.0 → 0.3.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/compile.d.ts +6 -0
- package/dist/files.d.ts +1 -0
- package/dist/files.js +3 -0
- package/dist/oxlint.d.ts +29 -3
- package/dist/oxlint.js +15 -4
- package/dist/vite.js +2 -1
- package/package.json +6 -6
package/dist/compile.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export interface CompilerOptions {
|
|
|
13
13
|
importSource?: string;
|
|
14
14
|
runtimeModule?: string;
|
|
15
15
|
development?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Audited render calls, keyed by import specifier and exported member path.
|
|
18
|
+
* These contracts promise immutable inputs, no observable effects or ambient
|
|
19
|
+
* reads, and no eager execution of unchecked callbacks. They do not load source.
|
|
20
|
+
*/
|
|
21
|
+
pureImports?: Readonly<Record<string, readonly string[]>>;
|
|
16
22
|
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
17
23
|
}
|
|
18
24
|
export interface CompilerResult {
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isCompilerFile(filename: string): boolean;
|
package/dist/files.js
ADDED
package/dist/oxlint.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { type CompilerOptions } from './compile.js';
|
|
1
2
|
type Source = {
|
|
2
3
|
text: string;
|
|
3
4
|
};
|
|
4
5
|
type Context = {
|
|
5
6
|
filename: string;
|
|
6
7
|
sourceCode: Source;
|
|
7
|
-
options: readonly
|
|
8
|
-
importSource?: string;
|
|
9
|
-
}[];
|
|
8
|
+
options: readonly Pick<CompilerOptions, 'importSource' | 'pureImports'>[];
|
|
10
9
|
report: (diagnostic: {
|
|
11
10
|
loc: {
|
|
12
11
|
line: number;
|
|
@@ -29,6 +28,15 @@ declare const _default: {
|
|
|
29
28
|
importSource: {
|
|
30
29
|
type: string;
|
|
31
30
|
};
|
|
31
|
+
pureImports: {
|
|
32
|
+
type: string;
|
|
33
|
+
additionalProperties: {
|
|
34
|
+
type: string;
|
|
35
|
+
items: {
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
32
40
|
};
|
|
33
41
|
additionalProperties: boolean;
|
|
34
42
|
}[];
|
|
@@ -46,6 +54,15 @@ declare const _default: {
|
|
|
46
54
|
importSource: {
|
|
47
55
|
type: string;
|
|
48
56
|
};
|
|
57
|
+
pureImports: {
|
|
58
|
+
type: string;
|
|
59
|
+
additionalProperties: {
|
|
60
|
+
type: string;
|
|
61
|
+
items: {
|
|
62
|
+
type: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
49
66
|
};
|
|
50
67
|
additionalProperties: boolean;
|
|
51
68
|
}[];
|
|
@@ -63,6 +80,15 @@ declare const _default: {
|
|
|
63
80
|
importSource: {
|
|
64
81
|
type: string;
|
|
65
82
|
};
|
|
83
|
+
pureImports: {
|
|
84
|
+
type: string;
|
|
85
|
+
additionalProperties: {
|
|
86
|
+
type: string;
|
|
87
|
+
items: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
66
92
|
};
|
|
67
93
|
additionalProperties: boolean;
|
|
68
94
|
}[];
|
package/dist/oxlint.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { diagnose } from './compile.js';
|
|
2
|
+
import { isCompilerFile } from './files.js';
|
|
2
3
|
const results = new WeakMap();
|
|
3
4
|
function rule(category) {
|
|
4
5
|
return {
|
|
@@ -7,7 +8,13 @@ function rule(category) {
|
|
|
7
8
|
schema: [
|
|
8
9
|
{
|
|
9
10
|
type: 'object',
|
|
10
|
-
properties: {
|
|
11
|
+
properties: {
|
|
12
|
+
importSource: { type: 'string' },
|
|
13
|
+
pureImports: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
additionalProperties: { type: 'array', items: { type: 'string' } },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
11
18
|
additionalProperties: false,
|
|
12
19
|
},
|
|
13
20
|
],
|
|
@@ -15,19 +22,23 @@ function rule(category) {
|
|
|
15
22
|
create(context) {
|
|
16
23
|
return {
|
|
17
24
|
Program() {
|
|
18
|
-
if (
|
|
25
|
+
if (!isCompilerFile(context.filename))
|
|
19
26
|
return;
|
|
20
27
|
const importSource = context.options[0]?.importSource ?? 'effectweb';
|
|
28
|
+
const pureImports = context.options[0]?.pureImports;
|
|
21
29
|
let cached = results.get(context.sourceCode);
|
|
22
30
|
if (!cached || cached.text !== context.sourceCode.text) {
|
|
23
31
|
cached = { text: context.sourceCode.text, diagnostics: new Map() };
|
|
24
32
|
results.set(context.sourceCode, cached);
|
|
25
33
|
}
|
|
26
|
-
const key = `${context.filename}\0${importSource}`;
|
|
34
|
+
const key = `${context.filename}\0${importSource}\0${JSON.stringify(pureImports)}`;
|
|
27
35
|
let diagnostics = cached.diagnostics.get(key);
|
|
28
36
|
if (!diagnostics) {
|
|
29
37
|
try {
|
|
30
|
-
diagnostics = diagnose(context.sourceCode.text, context.filename, {
|
|
38
|
+
diagnostics = diagnose(context.sourceCode.text, context.filename, {
|
|
39
|
+
importSource,
|
|
40
|
+
...(pureImports ? { pureImports } : {}),
|
|
41
|
+
});
|
|
31
42
|
}
|
|
32
43
|
catch (error) {
|
|
33
44
|
// Parser failures and unavailable native binaries must not silently pass lint.
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compile } from './compile.js';
|
|
2
|
+
import { isCompilerFile } from './files.js';
|
|
2
3
|
export function effectweb(options = {}) {
|
|
3
4
|
let development = false;
|
|
4
5
|
return {
|
|
@@ -15,7 +16,7 @@ export function effectweb(options = {}) {
|
|
|
15
16
|
enforce: 'pre',
|
|
16
17
|
transform(code, id) {
|
|
17
18
|
const filename = id.split('?')[0];
|
|
18
|
-
if (!filename ||
|
|
19
|
+
if (!filename || !isCompilerFile(filename))
|
|
19
20
|
return;
|
|
20
21
|
const result = compile(code, filename, {
|
|
21
22
|
...options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectweb/compiler",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Native Oxc compiler and Vite plugin for effectweb",
|
|
5
5
|
"homepage": "https://github.com/DerpyCrabs/EffectWeb",
|
|
6
6
|
"bugs": {
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"optionalDependencies": {
|
|
49
|
-
"@effectweb/compiler-darwin-arm64": "0.3.
|
|
50
|
-
"@effectweb/compiler-darwin-x64": "0.3.
|
|
51
|
-
"@effectweb/compiler-linux-arm64-gnu": "0.3.
|
|
52
|
-
"@effectweb/compiler-linux-x64-gnu": "0.3.
|
|
53
|
-
"@effectweb/compiler-win32-x64-msvc": "0.3.
|
|
49
|
+
"@effectweb/compiler-darwin-arm64": "0.3.1",
|
|
50
|
+
"@effectweb/compiler-darwin-x64": "0.3.1",
|
|
51
|
+
"@effectweb/compiler-linux-arm64-gnu": "0.3.1",
|
|
52
|
+
"@effectweb/compiler-linux-x64-gnu": "0.3.1",
|
|
53
|
+
"@effectweb/compiler-win32-x64-msvc": "0.3.1"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=22.14"
|