Skip to content

Commit

Permalink
Merge pull request #3 from aminya/browser [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Aug 20, 2022
2 parents 4127cd1 + 75a8b46 commit 1b6a83e
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 41 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
with:
node-version: ${{ matrix.node }}

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ stats.html
src/python/setup-python/
src/msvc/msvc-dev-cmd/
dev/cpp_vcpkg_project
package.json
2 changes: 2 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ignorePaths:
- dist/
- dev/cpp_vcpkg_project
words:
- deno
- denoland
- addShExt
- aarch
- aminya
Expand Down
2 changes: 1 addition & 1 deletion dev/tsc-mjs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { rename } from "fs/promises"
import { join } from "path"

async function main() {
const dir = "./dist"
const dir = "./dist/node"
await Promise.all(
readdirSync(dir).map((file) => {
return rename(join(dir, file), join(dir, file.replace(".js", ".mjs")))
Expand Down
90 changes: 61 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,62 @@
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": "./dist/node/index.mjs",
"require": "./dist/node/index.js"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/node/index.js",
"module": "./dist/node/index.mjs",
"main.browser": "./dist/browser/index.js",
"module.browser": "./dist/browser/index.mjs",
"main.deno": "./dist/deno/index.js",
"module.deno": "./dist/deno/index.mjs",
"source": "./src/index.ts",
"browser": {
"path": "./node_modules/path-browserify",
"process": "./node_modules/process"
},
"targets": {
"main": {
"context": "node",
"engines": {
"node": ">=12.x"
},
"optimize": true,
"includeNodeModules": true,
"outputFormat": "commonjs",
"isLibrary": false
},
"module": {
"context": "node",
"engines": {
"node": ">=16.x"
},
"optimize": true,
"includeNodeModules": true,
"outputFormat": "esmodule",
"isLibrary": false
},
"main.browser": {
"context": "browser",
"engines": {
"browsers": "> 0.5%"
},
"optimize": true,
"includeNodeModules": true,
"outputFormat": "global",
"isLibrary": true
},
"module.browser": {
"context": "browser",
"engines": {
"browsers": "last 2 versions"
},
"optimize": true,
"includeNodeModules": true,
"outputFormat": "esmodule",
"isLibrary": true
}
},
"files": [
"dist/",
"src/",
Expand All @@ -22,11 +72,11 @@
],
"scripts": {
"build": "run-s clean build.tsc.esm build.parcel",
"build.parcel": "shx rm -rf dist/index.js* && cross-env NODE_ENV=production parcel build --detailed-report",
"build.parcel": "shx rm -rf dist/node/index.js* && cross-env NODE_ENV=production parcel build --target main --target module --target main.browser --target module.browser && cp -r ./dist/browser/*.mjs* ./dist/deno",
"build.tsc.cjs": "tsc -p ./tsconfig.cjs.json",
"build.tsc.esm": "tsc -p ./tsconfig.json && node ./dev/tsc-mjs.mjs",
"bump": "ncu -u -x execa,numerous && pnpm update",
"clean": "shx rm -rf dist && shx mkdir ./dist",
"clean": "shx rm -rf dist && shx mkdir ./dist && shx mkdir ./dist/deno",
"dev": "cross-env NODE_ENV=development parcel watch",
"docs": "shx rm -rf ./README.md && pnpm exec readme --path ./dev/docs/readme.md -y && pnpm exec ts-readme --header-depth 3 && pnpm run format",
"format": "run-s lint.prettier",
Expand All @@ -36,7 +86,7 @@
"lint.prettier": "prettier --write .",
"prepare": "run-s build",
"test": "run-p --continue-on-error test.lint test.unit test.integration",
"test.integration": "run-s build && node ./test/integration.mjs && node ./test/integration.js",
"test.integration": "run-s build && node ./test/node-integration.mjs && node ./test/node-integration.js && deno run ./test/deno-integration.ts",
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.prettier",
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
"test.lint.prettier": "prettier . --check",
Expand Down Expand Up @@ -68,10 +118,9 @@
},
"optionalDependencies": {
"@types/node": "^18.6.3",
"@types/replace-ext": "^2.0.0"
},
"engines": {
"node": ">=12.x"
"@types/replace-ext": "^2.0.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10"
},
"keywords": [
"file-path",
Expand All @@ -86,9 +135,6 @@
"paths",
"path-plus"
],
"alias": {
"electron": false
},
"pnpm": {
"overrides": {
"eslint": "^8.21.0",
Expand All @@ -102,19 +148,5 @@
"eslint": "*"
}
}
},
"targets": {
"main": {
"context": "node",
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
},
"module": {
"context": "node",
"includeNodeModules": true,
"optimize": true,
"outputFormat": "esmodule"
}
}
}
}
19 changes: 18 additions & 1 deletion pnpm-lock.yaml

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

6 changes: 6 additions & 0 deletions test/deno-integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable import/no-unresolved */

import { name, normalizeTrim } from "../dist/deno/index.mjs"

name("path/to/file.md")
normalizeTrim("/foo/../")
7 changes: 0 additions & 7 deletions test/integration.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion test/integration.js → test/node-integration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const filePaths = require("../dist/index.js")
const filePaths = require("../dist/node/index.js")
const { name, normalizeTrim } = filePaths

name("path/to/file.md")
Expand Down
7 changes: 7 additions & 0 deletions test/node-integration.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable import/no-unresolved */

import { name } from "../dist/node/index.mjs"
import { normalizeTrim } from "../dist/node/normalize-trim.mjs"

name("path/to/file.md")
normalizeTrim("/foo/../")
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"module": "ESNext",
"moduleResolution": "node",
"importHelpers": false,
"outDir": "./dist"
"outDir": "./dist/node"
},
"compileOnSave": false,
"include": ["./src"]
Expand Down

0 comments on commit 1b6a83e

Please sign in to comment.