Skip to content

Commit d0ffc36

Browse files
committed
Migrate build from babel to tsup
1 parent 9875469 commit d0ffc36

25 files changed

+1430
-4609
lines changed

.babelrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.editorconfig

Lines changed: 0 additions & 15 deletions
This file was deleted.

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,11 @@ pids
88
*.pid
99
*.seed
1010

11-
# Directory for instrumented libs generated by jscoverage/JSCover
12-
lib-cov
13-
14-
# Coverage directory used by tools like istanbul
15-
coverage
16-
17-
# nyc test coverage
18-
.nyc_output
19-
20-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21-
.grunt
22-
23-
# node-waf configuration
24-
.lock-wscript
25-
26-
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
28-
2911
# Dependency directories
3012
node_modules
31-
jspm_packages
32-
33-
# Optional npm cache directory
34-
.npm
35-
36-
# Optional REPL history
37-
.node_repl_history
38-
39-
# Editors
40-
.idea
4113

42-
# Lib
43-
lib
14+
# Build artifacts
15+
dist
4416

45-
# npm package lock
46-
package-lock.json
17+
# Others
18+
.DS_Store

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
pnpm-lock.yaml
3+
# Ignore all MD files:
4+
**/*.md
5+
6+
# Ignore artifacts:
7+
dist

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 Dineshkumar Pandiyan <[email protected]>
3+
Copyright (c) 2023 Dinesh Pandiyan <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Browser or Node.js
22

3-
[![Build Status](https://travis-ci.org/flexdinesh/browser-or-node.svg?branch=master)](https://travis-ci.org/flexdinesh/browser-or-node)
43
[![npm version](https://badge.fury.io/js/browser-or-node.svg)](https://www.npmjs.com/package/browser-or-node)
54
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
65

7-
Check whether the code is running in the browser or node.js runtime.
6+
Check in which environment the code is running - browser/node.js/webworker/jsdom/deno.
87

98
## Install
109

@@ -14,36 +13,12 @@ $ npm install --save browser-or-node
1413

1514
## Usage
1615

17-
ES6 style import
16+
Import the checks and use it in your code. Works with both ESM and CJS imports.
1817

1918
```js
20-
import { isBrowser, isNode, isWebWorker, isJsDom, isDeno } from "browser-or-node";
21-
22-
if (isBrowser) {
23-
// do browser only stuff
24-
}
25-
26-
if (isNode) {
27-
// do node.js only stuff
28-
}
29-
30-
if (isWebWorker) {
31-
// do web worker only stuff
32-
}
33-
34-
if (isJsDom) {
35-
// do jsdom only stuff
36-
}
37-
38-
if (isDeno) {
39-
// do deno only stuff
40-
}
41-
```
42-
43-
ES5 style import
44-
45-
```js
46-
var jsEnv = require("browser-or-node");
19+
import * as jsEnv from "browser-or-node";
20+
// import { isBrowser, isNode, isWebWorker, isJsDom, isDeno } from "browser-or-node";
21+
// const jsEnv = require("browser-or-node");
4722

4823
if (jsEnv.isBrowser) {
4924
// do browser only stuff
@@ -68,4 +43,4 @@ if (jsEnv.isDeno) {
6843

6944
## License
7045

71-
MIT © Dineshkumar Pandiyan
46+
MIT © Dinesh Pandiyan

browser-test/index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

browser-test/index.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

browser-test/package.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

browser-test/server.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

browser-test/worker.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/example.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
22
"name": "browser-or-node",
3-
"version": "2.1.1",
4-
"description": "Check where the code is running in the browser or node.js",
5-
"main": "./lib/index.js",
6-
"types": "./lib/index.d.ts",
3+
"version": "3.0.0",
4+
"description": "Check in which environment the code is running - browser/node.js/webworker/jsdom/deno",
5+
"main": "./dist/index.js",
6+
"module": "./dist/index.mjs",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"require": "./dist/index.js",
11+
"import": "./dist/index.mjs",
12+
"types": "./dist/index.d.ts"
13+
}
14+
},
715
"scripts": {
8-
"clean": "rimraf lib",
9-
"test": "npm run cover",
10-
"test:only": "cross-env BABEL_ENV=commonjs mocha --require babel-core/register --recursive",
11-
"test:watch": "npm test -- --watch",
12-
"test:examples": "node examples/",
13-
"cover": "cross-env BABEL_ENV=commonjs istanbul cover node_modules/mocha/bin/_mocha -- --require babel-core/register --recursive",
14-
"lint": "eslint src",
15-
"build": "cross-env BABEL_ENV=commonjs babel src --out-dir lib --copy-files",
16-
"prepublish": "npm run clean && npm run lint && npm run test && npm run build"
16+
"build": "tsup",
17+
"prepublishOnly": "npm run build"
1718
},
1819
"files": [
19-
"lib",
20+
"dist",
2021
"src"
2122
],
2223
"repository": {
@@ -31,31 +32,11 @@
3132
"is node",
3233
"is browser node"
3334
],
34-
"author": "Dineshkumar Pandiyan <[email protected]>",
35-
"contributors": [
36-
"Daniel Wang <[email protected]> (https://github.com/dan1wang/)"
37-
],
3835
"license": "MIT",
39-
"bugs": {
40-
"url": "https://github.com/flexdinesh/browser-or-node/issues"
41-
},
4236
"homepage": "https://github.com/flexdinesh/browser-or-node#readme",
4337
"devDependencies": {
44-
"babel": "^6.23.0",
45-
"babel-cli": "^6.26.0",
46-
"babel-eslint": "^10.1.0",
47-
"babel-plugin-add-module-exports": "^1.0.2",
48-
"babel-preset-es2015": "^6.24.1",
49-
"babel-preset-stage-2": "^6.24.1",
50-
"chai": "^4.2.0",
51-
"cross-env": "^7.0.2",
52-
"eslint": "^7.3.1",
53-
"eslint-config-prettier": "^8.3.0",
54-
"eslint-plugin-import": "^2.21.2",
55-
"eslint-plugin-jsx-a11y": "^6.3.1",
56-
"eslint-plugin-react": "^7.20.0",
57-
"istanbul": "^1.0.0-alpha",
58-
"mocha": "^8.0.1",
59-
"rimraf": "^3.0.2"
38+
"prettier": "3.1.0",
39+
"tsup": "^7.3.0",
40+
"typescript": "^5.2.2"
6041
}
6142
}

0 commit comments

Comments
 (0)