@surplus/esbuild 0.2.1 → 1.0.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.
Files changed (4) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +9 -7
  3. package/index.mjs +27 -12
  4. package/package.json +8 -4
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2023-2025 Josh Junon
2
+ Copyright (c) 2017 Adam Haile
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the “Software”), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
package/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  Javascript framework.
5
5
 
6
6
  > **NOTE:** This plugin strips typescript types from the output.
7
- > If this is affecting you negatively, please
8
- > [open an issue](https://github.com/surplus/surplus/issues).
7
+ > If this is affecting you negatively, please open an issue
8
+ > with the [compiler](https://github.com/surplus/compiler/issues).
9
9
 
10
10
  ## Usage
11
11
 
@@ -16,22 +16,24 @@ yarn add -D @surplus/esbuild
16
16
  ```
17
17
 
18
18
  ```js
19
- import esbuild from 'esbuild';
20
- import surplus from '@surplus/esbuild';
19
+ import esbuild from "esbuild";
20
+ import surplus from "@surplus/esbuild";
21
21
 
22
22
  const surplusOptions = {
23
23
  /* see @surplus/compiler for options */
24
24
  };
25
25
 
26
26
  await esbuild.build({
27
- entryPoints: ['app.js'],
27
+ entryPoints: ["app.js"],
28
28
  bundle: true,
29
29
  minify: true,
30
- outfile: 'out.js',
31
- plugins: [surplus(surplusOptions)] // options are optional
30
+ outfile: "out.js",
31
+ plugins: [surplus(surplusOptions)], // options are optional
32
32
  });
33
33
  ```
34
34
 
35
35
  # License
36
36
 
37
+ Copyright © 2023-2025 Josh Junon.
38
+
37
39
  Released under the [MIT License](LICENSE).
package/index.mjs CHANGED
@@ -1,28 +1,43 @@
1
- import fsp from 'node:fs/promises';
1
+ import fsp from "node:fs/promises";
2
2
 
3
- import compileSurplus from '@surplus/compiler';
3
+ import { compile } from "@surplus/compiler";
4
4
 
5
- export default opts => ({
6
- name: 'surplus',
5
+ const BASE_RESULT = {
6
+ pluginName: 'Surplus Compiler'
7
+ };
8
+
9
+ export default (opts) => ({
10
+ name: "surplus",
7
11
  setup(build) {
8
- const fileExtensions = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'];
12
+ const fileExtensions = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
9
13
 
10
14
  for (let ext of fileExtensions) {
11
- build.onLoad({ filter: new RegExp(`\\${ext}$`) }, async args => {
15
+ build.onLoad({ filter: new RegExp(`\\${ext}$`) }, async (args) => {
12
16
  try {
13
- const source = await fsp.readFile(args.path, 'utf8');
17
+ const source = await fsp.readFile(args.path, "utf8");
14
18
 
15
- const transpiled = compileSurplus(source, opts);
19
+ const result = compile({
20
+ source,
21
+ minify: false,
22
+ sourcemapFilename: args.path,
23
+ ...opts
24
+ });
16
25
 
17
26
  return {
18
- contents: transpiled,
19
- loader: 'default'
27
+ ...BASE_RESULT,
28
+ contents: result.code,
29
+ errors: result.errors?.map(err => ({text: err})),
30
+ warnings: result.warnings?.map(err => ({text: err})),
31
+ loader: "default",
20
32
  };
21
33
  } catch (err) {
22
34
  // Handle any errors from the transpiler
23
- return { errors: [{ text: err.message }] };
35
+ return {
36
+ ...BASE_RESULT,
37
+ errors: [{ text: err.message }]
38
+ };
24
39
  }
25
40
  });
26
41
  }
27
- }
42
+ },
28
43
  });
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@surplus/esbuild",
3
- "version": "0.2.1",
3
+ "version": "1.0.0",
4
4
  "description": "Surplus framework ESBuild plugin",
5
5
  "author": "Josh Junon (https://github.com/qix-)",
6
6
  "license": "MIT",
7
- "repository": "surplus/surplus",
8
- "funding": "https://github.com/surplus/surplus?sponsor=1",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/surplus/esbuild"
10
+ },
11
+ "funding": "https://github.com/surplus/esbuild?sponsor=1",
12
+ "homepage": "https://github.com/surplus",
9
13
  "main": "index.mjs",
10
14
  "type": "module",
11
15
  "keywords": [
@@ -20,7 +24,7 @@
20
24
  "README.md"
21
25
  ],
22
26
  "dependencies": {
23
- "@surplus/compiler": "^0.1.2"
27
+ "@surplus/compiler": "^1.0.0"
24
28
  },
25
29
  "engines": {
26
30
  "node": "^12.17.0 || ^14.13 || >=16.0.0"