Skip to content

Commit

Permalink
mjs (esm) & cjs build;"type": "module"
Browse files Browse the repository at this point in the history
	fixes juliangruber#37

update dependencies
  • Loading branch information
btakita committed Jul 27, 2022
1 parent f02208f commit c862a0b
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function ({ version, experimental }?: {
version?: string | undefined;
experimental?: boolean | undefined;
}): string[];
23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,31 @@
"description": "List of node.js builtin modules",
"repository": "juliangruber/builtins",
"license": "MIT",
"main": "index.js",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/mjs/index.js"
}
},
"types": "./dist/mjs/index.d.ts",
"files": [],
"scripts": {
"test": "standard --fix && node--test"
"build": "rimraf cjs/**,mjs/** && tsc -p tsconfig.cjs.json && tsc -p tsconfig.mjs.json",
"release": "np",
"test": "node test.js"
},
"dependencies": {
"semver": "^7.0.0"
"semver": "github:MylesBorins/node-semver#alternative-esm"
},
"devDependencies": {
"np": "^7.6.2",
"prettier-standard": "^16.4.1",
"rimraf": "^3.0.2",
"standard": "^17.0.0",
"test": "^3.0.0"
"tape": "^5.5.3",
"typescript": "^4.7.4"
}
}
4 changes: 2 additions & 2 deletions index.js → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const semver = require('semver')
import semver from 'semver'

const permanentModules = [
'assert',
Expand Down Expand Up @@ -56,7 +56,7 @@ const experimentalModules = {
diagnostics_channel: '^14.17.0 || >=15.1.0'
}

module.exports = ({ version = process.version, experimental = false } = {}) => {
export default ({ version = process.version, experimental = false } = {}) => {
const builtins = [...permanentModules]

for (const [name, semverRange] of Object.entries(versionLockedModules)) {
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "dist/cjs",
"declarationDir": "dist/cjs"
}
}
18 changes: 18 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es2019",
"module": "ESNext",
"declaration": true,
"rootDir": "src",
"outDir": "dist/mjs",
"declarationDir": "dist/mjs",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["mjs"]
}
7 changes: 7 additions & 0 deletions tsconfig.mjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist/mjs",
"declarationDir": "dist/mjs"
}
}

0 comments on commit c862a0b

Please sign in to comment.