Skip to content

Commit f685f72

Browse files
committed
New attempt to get valid browser friendly export
1 parent 6bf3aaf commit f685f72

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.config/cspell-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ sonarlint
1111
sonarsource
1212
sublist
1313
temurin
14+
userscript
1415
Warmerdam

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
// @ts-check
44
const { defineConfig } = require("eslint-define-config");
5+
const { sortOrder: defaultSortOrder } = require("sort-package-json");
56

67
/// <reference types="@eslint-types/prettier" />
78

9+
// Make sure that the `userscript` dist target is near other dist targets (main, module, browser).
10+
const index = defaultSortOrder.indexOf("browser");
11+
const sortOrder = defaultSortOrder.splice(index + 1, 0, "userscript");
12+
813
module.exports = defineConfig({
914
root: true,
1015
env: {
@@ -84,7 +89,7 @@ module.exports = defineConfig({
8489
"json-files/require-engines": "error",
8590
"json-files/require-license": "error",
8691
"json-files/require-unique-dependency-names": "error",
87-
"json-files/sort-package-json": "error",
92+
"json-files/sort-package-json": ["error", { sortOrder }],
8893
},
8994
},
9095

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"main": "dist/main.js",
2020
"module": "dist/module.js",
2121
"source": "src/index.mjs",
22+
"browser": "dist/browser.js",
23+
"userscript": "dist/userscript.js",
2224
"types": "types/index.d.ts",
2325
"scripts": {
2426
"build": "parcel build",
@@ -53,5 +55,15 @@
5355
},
5456
"engines": {
5557
"node": ">=16.0.0"
58+
},
59+
"targets": {
60+
"userscript": {
61+
"isLibrary": false,
62+
"scopeHoist": false,
63+
"context": "browser",
64+
"outputFormat": "global",
65+
"optimize": false
66+
},
67+
"types": false
5668
}
5769
}

0 commit comments

Comments
 (0)