Skip to content

Commit

Permalink
Move standalone to type: module.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwilsonvu committed Apr 13, 2024
1 parent 54a2562 commit cf3a025
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
dist.*
./configs
node_modules
jest.config.js
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Build directory
dist
standalone/dist.mjs
standalone/dist.mjs.map
dist.*

# Logs
logs
Expand Down
7 changes: 4 additions & 3 deletions standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "eslint-solid-standalone",
"version": "0.13.2",
"description": "A bundle with eslint and eslint-plugin-solid that can be used in the browser.",
"type": "module",
"files": [
"dist.mjs",
"dist.js",
"dist.d.ts",
"dist.mjs.map",
"dist.js.map",
"README.md"
],
"main": "dist.mjs",
"main": "dist.js",
"types": "dist.d.ts",
"repository": "https://github.com/solidjs-community/eslint-plugin-solid",
"author": "Josh Wilson <joshwilsonvu@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion standalone/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
interop: "auto",
freeze: false,
sourcemap: true,
file: "dist.mjs",
file: "dist.js",
},
external: ["vs/language/typescript/tsWorker", "typescript"],
plugins: [
Expand Down
10 changes: 5 additions & 5 deletions standalone/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import vm from "node:vm";
import typescript from "typescript";

/**
* Test that dist.mjs can be run in a clean environment without Node or browser APIs, that it won't
* Test that dist.js can be run in a clean environment without Node or browser APIs, that it won't
* crash, and that it will produce expected results. Code in, lints/fixes out is all it needs to do.
*/

Expand All @@ -17,8 +17,8 @@ const context = vm.createContext({
});

// create a module with the standalone build
const code = fs.readFileSync(path.resolve("dist.mjs"), "utf-8");
const dist = new vm.SourceTextModule(code, { identifier: "dist.mjs", context });
const code = fs.readFileSync(path.resolve("dist.js"), "utf-8");
const dist = new vm.SourceTextModule(code, { identifier: "dist.js", context });

// create a module reexporting typescript, a peer dependency of the standalone build
const ts = new vm.SourceTextModule("export default _TYPESCRIPT_GLOBAL", {
Expand All @@ -29,7 +29,7 @@ const ts = new vm.SourceTextModule("export default _TYPESCRIPT_GLOBAL", {
// create a module that tests the build with `assert`
const test = new vm.SourceTextModule(
`
import { plugin, pluginVersion, eslintVersion, verify, verifyAndFix } from "dist.mjs";
import { plugin, pluginVersion, eslintVersion, verify, verifyAndFix } from "dist.js";
// check no Node APIs are present, except injected 'assert' and '_TYPESCRIPT_GLOBAL'
assert.equal(Object.keys(globalThis).length, 2);
Expand Down Expand Up @@ -72,7 +72,7 @@ assert.deepStrictEqual(verifyAndFix('let el = <div className="red" />'), {
const linker = (specifier) => {
const mod = {
typescript: ts,
"dist.mjs": dist,
"dist.js": dist,
}[specifier];
if (!mod) {
throw new Error("can't import other modules");
Expand Down

0 comments on commit cf3a025

Please sign in to comment.