Skip to content

Commit

Permalink
fix: module.exports present in ESM bundle (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip authored Mar 29, 2023
1 parent 9286354 commit bd613dc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo 'extends: ["@stoplight/spectral-url-versioning"]' > .spectral.yaml
_If you're using VS Code or Stoplight Studio then the NPM modules will not be available. Instead you can use the CDN hosted version:_

```
echo 'extends: ["https://unpkg.com/@stoplight/spectral-url-versioning@1.0.4/dist/ruleset.js"]' > .spectral.yaml
echo 'extends: ["https://unpkg.com/@stoplight/spectral-url-versioning/dist/ruleset.mjs"]' > .spectral.yaml
```

_**Note:** You need to use the full URL with CDN hosted rulesets because Spectral [cannot follow redirects through extends](https://github.com/stoplightio/spectral/issues/2266)._
Expand Down
21 changes: 0 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,5 @@
"ts-jest": "^28.0",
"tsup": "^6.2.3",
"typescript": "^4.8.4"
},
"tsup": {
"entry": [
"src/ruleset.ts"
],
"clean": true,
"dts": true,
"format": [
"cjs",
"esm"
],
"sourcemap": true,
"noExternal": [
"@stoplight/types"
],
"external": [
"@stoplight/spectral-core"
],
"footer": {
"js": "module.exports = module.exports.default;"
}
}
}
21 changes: 21 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Options } from 'tsup';

export default <Options>{
entry: ["src/ruleset.ts"],
clean: true,
dts: true,
target: "es2018",
format: ["cjs", "esm"],
sourcemap: true,
noExternal: ["@stoplight/types"],
external: ["@stoplight/spectral-core"],
footer({ format }) {
if (format === "cjs") {
return {
js: "module.exports = module.exports.default;",
};
}

return {};
},
};

0 comments on commit bd613dc

Please sign in to comment.