@surplus/esbuild 1.0.0 → 1.1.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/index.mjs +24 -7
- package/package.json +9 -2
package/index.mjs
CHANGED
|
@@ -3,15 +3,21 @@ import fsp from "node:fs/promises";
|
|
|
3
3
|
import { compile } from "@surplus/compiler";
|
|
4
4
|
|
|
5
5
|
const BASE_RESULT = {
|
|
6
|
-
pluginName:
|
|
6
|
+
pluginName: "Surplus Compiler",
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export default (opts) => ({
|
|
10
10
|
name: "surplus",
|
|
11
11
|
setup(build) {
|
|
12
|
-
const
|
|
12
|
+
const jsFileExtensions = [".js", ".jsx", ".mjs", ".cjs"];
|
|
13
|
+
const tsFileExtensions = [".ts", ".tsx"];
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const fileExtensions = [
|
|
16
|
+
...jsFileExtensions.map((e) => [e, false]),
|
|
17
|
+
...tsFileExtensions.map((e) => [e, true]),
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
for (const [ext, ts] of fileExtensions) {
|
|
15
21
|
build.onLoad({ filter: new RegExp(`\\${ext}$`) }, async (args) => {
|
|
16
22
|
try {
|
|
17
23
|
const source = await fsp.readFile(args.path, "utf8");
|
|
@@ -20,21 +26,32 @@ export default (opts) => ({
|
|
|
20
26
|
source,
|
|
21
27
|
minify: false,
|
|
22
28
|
sourcemapFilename: args.path,
|
|
23
|
-
|
|
29
|
+
typescript: ts,
|
|
30
|
+
...opts,
|
|
24
31
|
});
|
|
25
32
|
|
|
33
|
+
if (result.errors.length > 0) {
|
|
34
|
+
return {
|
|
35
|
+
...BASE_RESULT,
|
|
36
|
+
errors: result.errors?.map((err) => ({
|
|
37
|
+
text: err,
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
return {
|
|
27
43
|
...BASE_RESULT,
|
|
28
44
|
contents: result.code,
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
warnings: result.warnings?.map((err) => ({
|
|
46
|
+
text: err,
|
|
47
|
+
})),
|
|
31
48
|
loader: "default",
|
|
32
49
|
};
|
|
33
50
|
} catch (err) {
|
|
34
51
|
// Handle any errors from the transpiler
|
|
35
52
|
return {
|
|
36
53
|
...BASE_RESULT,
|
|
37
|
-
errors: [{ text: err.message }]
|
|
54
|
+
errors: [{ text: err.message }],
|
|
38
55
|
};
|
|
39
56
|
}
|
|
40
57
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surplus/esbuild",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Surplus framework ESBuild plugin",
|
|
5
5
|
"author": "Josh Junon (https://github.com/qix-)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,18 +18,25 @@
|
|
|
18
18
|
"esbuild",
|
|
19
19
|
"plugin"
|
|
20
20
|
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"format": "prettier -w .",
|
|
23
|
+
"lint": "prettier -c ."
|
|
24
|
+
},
|
|
21
25
|
"files": [
|
|
22
26
|
"index.mjs",
|
|
23
27
|
"LICENSE",
|
|
24
28
|
"README.md"
|
|
25
29
|
],
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@surplus/compiler": "^1.
|
|
31
|
+
"@surplus/compiler": "^1.1.0"
|
|
28
32
|
},
|
|
29
33
|
"engines": {
|
|
30
34
|
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
31
35
|
},
|
|
32
36
|
"publishConfig": {
|
|
33
37
|
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"prettier": "^3.6.2"
|
|
34
41
|
}
|
|
35
42
|
}
|