unplugin-oxc 0.2.0 → 0.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/esbuild.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/esbuild.ts
4
4
  /**
package/dist/farm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/farm.ts
4
4
  /**
package/dist/index.d.ts CHANGED
@@ -32,6 +32,9 @@ interface Options {
32
32
  * Minify options passed to `oxc-minify`
33
33
  */
34
34
  minify?: Omit<MinifyOptions, "sourcemap"> | false;
35
+ /**
36
+ * Default: `true` on unloader, `false` on others.
37
+ */
35
38
  sourcemap?: boolean;
36
39
  }
37
40
 
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  export { Oxc };
package/dist/rolldown.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/rolldown.ts
4
4
  /**
package/dist/rollup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/rollup.ts
4
4
  /**
package/dist/rspack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/rspack.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { createUnplugin } from "unplugin";
7
7
  import { createFilter } from "unplugin-utils";
8
8
 
9
9
  //#region src/core/options.ts
10
- function resolveOptions(options) {
10
+ function resolveOptions(options, framework) {
11
11
  return {
12
12
  include: options.include || [/\.[cm]?[jt]sx?$/],
13
13
  exclude: options.exclude || [/node_modules/],
@@ -16,14 +16,14 @@ function resolveOptions(options) {
16
16
  resolve: options.resolve || {},
17
17
  resolveNodeModules: options.resolveNodeModules || false,
18
18
  minify: options.minify || false,
19
- sourcemap: options.sourcemap || false
19
+ sourcemap: options.sourcemap ?? framework === "unloader"
20
20
  };
21
21
  }
22
22
 
23
23
  //#endregion
24
24
  //#region src/index.ts
25
- const Oxc = createUnplugin((rawOptions = {}) => {
26
- const options = resolveOptions(rawOptions);
25
+ const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
26
+ const options = resolveOptions(rawOptions, framework);
27
27
  const filter = createFilter(options.include, options.exclude);
28
28
  const renderChunk = options.minify !== false ? (code, chunk) => {
29
29
  const result = minify(chunk.fileName, code, {
@@ -61,6 +61,7 @@ const Oxc = createUnplugin((rawOptions = {}) => {
61
61
  ...options.transform,
62
62
  sourcemap: options.sourcemap
63
63
  });
64
+ if (result.errors.length) throw new SyntaxError(result.errors.map((error) => error.message).join("\n"));
64
65
  return {
65
66
  code: result.code,
66
67
  map: result.map
@@ -69,11 +70,16 @@ const Oxc = createUnplugin((rawOptions = {}) => {
69
70
  rollup: { renderChunk },
70
71
  rolldown: { renderChunk },
71
72
  vite: { renderChunk },
72
- unloader: { async load(id) {
73
- if (!filter(id)) return;
74
- const contents = await readFile(id, "utf8");
75
- return contents;
76
- } }
73
+ unloader: {
74
+ options(config) {
75
+ config.sourcemap ||= options.sourcemap;
76
+ },
77
+ async load(id) {
78
+ if (!filter(id)) return;
79
+ const contents = await readFile(id, "utf8");
80
+ return contents;
81
+ }
82
+ }
77
83
  };
78
84
  });
79
85
 
package/dist/unloader.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/unloader.ts
4
4
  /**
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/vite.ts
4
4
  /**
package/dist/webpack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Oxc } from "./src-DBx3R6Bc.js";
1
+ import { Oxc } from "./src-C7AaF2B_.js";
2
2
 
3
3
  //#region src/webpack.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-oxc",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Oxc integration for unplugin.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -65,7 +65,7 @@
65
65
  "unplugin-utils": "^0.2.3"
66
66
  },
67
67
  "devDependencies": {
68
- "@sxzz/eslint-config": "^5.0.1",
68
+ "@sxzz/eslint-config": "^5.0.2",
69
69
  "@sxzz/prettier-config": "^2.1.2",
70
70
  "@sxzz/test-utils": "^0.5.1",
71
71
  "@types/node": "^22.13.1",