Skip to content

Commit

Permalink
fix: rename to builTerserOptions + add missing deps
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 7, 2023
1 parent e77e7a3 commit 5bc0cc5
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 47 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ The config is adapted based on `NODE_ENV`, so make sure to run your scripts with
You can import the builder function to create a custom config:

```ts
import { getTerserOptions } from "terser-config-atomic/dist/index.js"
module.exports = getTerserOptions(process.env.NODE_ENV, process.env.BABEL_ENV)
import { buildTerserOptions } from "terser-config-atomic/dist/builder.js"
module.exports = buildTerserOptions(process.env.NODE_ENV, process.env.BABEL_ENV)
```

The builder function:
Expand All @@ -62,7 +62,7 @@ The builder function:
@param BABEL_ENV - The Babel environment (defaults to NODE_ENV).
@param unsafeCompress - Whether to use unsafe compression options (defaults to false).
*/
export function getTerserOptions(
export function buildTerserOptions(
NODE_ENV: string = "production",
BABEL_ENV: string | undefined = undefined,
unsafeCompress: boolean = false,
Expand Down
8 changes: 4 additions & 4 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from "assert"
import { getTerserOptions } from "../src"
import { buildTerserOptions } from "../src/builder"

describe("Terser-Config-Atomic", () => {
it("production", () => {
const TerserOptions = getTerserOptions("production", undefined)
const TerserOptions = buildTerserOptions("production", undefined)

expect(typeof TerserOptions).toBe("object")
assert(typeof TerserOptions.compress === "object")
Expand All @@ -20,7 +20,7 @@ describe("Terser-Config-Atomic", () => {
it("development", () => {
process.env.NODE_ENV = "development"

const TerserOptions = getTerserOptions("development", undefined)
const TerserOptions = buildTerserOptions("development", undefined)

expect(typeof TerserOptions).toBe("object")
expect(TerserOptions.compress).toBe(false)
Expand All @@ -30,7 +30,7 @@ describe("Terser-Config-Atomic", () => {
it("test", () => {
process.env.NODE_ENV = "test"

const TerserOptions = getTerserOptions("test", undefined)
const TerserOptions = buildTerserOptions("test", undefined)

expect(typeof TerserOptions).toBe("object")
assert(typeof TerserOptions.compress === "object")
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "terser-config-atomic",
"dist": "./dist/.terserrc.js",
"main": "dist/terserrc.js",
"version": "0.1.1",
"files": [
"src"
"src",
"dist"
],
"author": "Amin Yahyaabadi",
"description": "The Terser configuration used in atom-community",
Expand All @@ -16,7 +17,7 @@
"repository": "https://github.com/atom-community/terser-config-atomic",
"license": "MIT",
"scripts": {
"build": "tsc",
"build": "tsc -p tsconfig.build.json",
"prepublishOnly": "npm run build",
"format": "prettier --write .",
"test.format": "prettier . --check",
Expand All @@ -29,11 +30,13 @@
"devDependencies": {
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.9",
"eslint": "^8.48.0",
"eslint-config-atomic": "^1.19.3",
"jest": "^29.6.4",
"prettier": "^3.0.3",
"prettier-config-atomic": "^3.1.0",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
70 changes: 38 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/.terserrc.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts → src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@param BABEL_ENV - The Babel environment (defaults to NODE_ENV).
@param unsafeCompress - Whether to use unsafe compression options (defaults to false).
*/
export function getTerserOptions(
export function buildTerserOptions(
NODE_ENV: string = "production",
BABEL_ENV: string | undefined = undefined,
unsafeCompress: boolean = false,
Expand Down
2 changes: 2 additions & 0 deletions src/terserrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { buildTerserOptions } from "./builder.js"
module.exports = buildTerserOptions(process.env.NODE_ENV, process.env.BABEL_ENV)
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["./src/"]
}
Loading

0 comments on commit 5bc0cc5

Please sign in to comment.