-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modules): build (true) esm, (interop) cjs modules; tests/readme (#…
…144) * chore(esm): initial esm work * chore(esm): don't force engines while we still support CJS * chore(tests): jest.config.js -> .ts, export, add dev ts-node * chore(tests): update jest.config.ts to ignore /dist/ not /api/ * chore(env): import, not require deps. add @types/node-fetch * chore(tests): ts-ignore yahooFinanceFetch partial bind * chore(esm): replace require with import, add .js - breaks stuff * chore(esm): package/jest/tsconfig bump deps, esm opts * chore(esm): fix manual conflict resolution for import type Optsions * chore(esm): more node/jest config opts for esm, setupTests, setGlobal * chore(esm): import jest global in tests * use relative paths in package.json for main/exports/types/browser * eureka * fetchDevel: use URL paths * yahooFinanceFetch: this && this._env check * yahooFinanceFetch: remove console.log * historical.spec.ts ts-ignore * schema-tweak.js * ci fix, update node image for es2020 for dynamic import * yahoo-finance.js bin * package.json: add "module" field, expand "exports" * build:cjs - change package.json "type" * yarn.lock: recreate to fix missed conflicts in rebase * update schema * readme note * gitignore: add /api temporarily to make switching branches easier * more README notes * sanity tests * test:build * ci: test builds * separate test root for modules * prettier fix
- Loading branch information
Showing
50 changed files
with
1,089 additions
and
1,314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/node_modules | ||
/coverage | ||
/dist | ||
/api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { Config } from "@jest/types"; | ||
|
||
const config: Config.InitialOptions = { | ||
preset: "ts-jest/presets/default-esm", | ||
setupFilesAfterEnv: ["<rootDir>/tests/setupTests.js"], | ||
testEnvironment: "node", | ||
testPathIgnorePatterns: [ | ||
"/node_modules/", | ||
"/dist/", | ||
"/api/", | ||
"/tests-modules/", | ||
], | ||
extensionsToTreatAsEsm: [".ts"], | ||
globals: { | ||
"ts-jest": { | ||
useESM: true, | ||
}, | ||
}, | ||
moduleNameMapper: { | ||
"(.*)\\.js$": "$1", | ||
}, | ||
/* | ||
reporters: [ | ||
'<rootDir>/tests/reporter.js', | ||
'<rootDir>/tests/summary-reporter.js', | ||
], | ||
*/ | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,15 @@ | |
"name": "yahoo-finance2", | ||
"version": "0.0.1", | ||
"description": "JS API for Yahoo Finance", | ||
"main": "api/index-node.js", | ||
"types": "api/index-node.d.ts", | ||
"browser": "api/index-browser.js", | ||
"type": "module", | ||
"module": "./dist/esm/src/index-node.js", | ||
"main": "./dist/cjs/src/index-node.js", | ||
"exports": { | ||
"import": "./dist/esm/src/index-node.js", | ||
"default": "./dist/cjs/src/index-node.js" | ||
}, | ||
"types": "./dist/esm/src/index-node.d.ts", | ||
"browser": "./dist/esm/src/index-browser.js", | ||
"repository": "https://github.com/gadicc/node-yahoo-finance2", | ||
"author": "Gadi Cohen <[email protected]>", | ||
"license": "MIT", | ||
|
@@ -22,20 +28,32 @@ | |
"client", | ||
"library" | ||
], | ||
"//engines//UNCOMMENT_WHEN_WE_DROP_CJS_SUPPORT": { | ||
"node": ">=12.17.0", | ||
"//node2": "we need 14.x for dynamic imports -- JUST FOR FETCH_DEVEL()! think about this.", | ||
"node2": ">=14.0.0" | ||
}, | ||
"bin": { | ||
"yahoo-finance": "bin/yahoo-finance.js" | ||
}, | ||
"scripts": { | ||
"coverage": "jest --coverage", | ||
"lint": "eslint . --ext .js,.ts", | ||
"schema": "ts-json-schema-generator -f tsconfig.json -p 'src/{modules,typings}/**/*.ts' -t '*' | node bin/schema-tweak.js > schema.json", | ||
"build": "yarn run build:esm && yarn run build:cjs", | ||
"build:esm": "tsc --module es2020 --outDir dist/esm", | ||
"build:cjs": "tsc --module commonjs --outDir dist/cjs && sed -i 's/\"type\": \"module\",/\"type:\": \"commonjs\",/' dist/cjs/package.json", | ||
"generateSchema": "yarn schema", | ||
"prepublishOnly": "tsc && yarn generateSchema", | ||
"test": "jest", | ||
"test:ts": "tsc --noEmit" | ||
"prepublishOnly": "yarn build && yarn generateSchema", | ||
"test": "node --experimental-vm-modules node_modules/.bin/jest", | ||
"test:ts": "tsc --noEmit", | ||
"test:esm": "node --experimental-vm-modules node_modules/.bin/jest -c tests-modules/esm/jest.config.js tests-modules/esm/tests/*", | ||
"test:cjs": "node node_modules/.bin/jest -c tests-modules/cjs/jest.config.js tests-modules/cjs/tests/*", | ||
"test:modules": "yarn test:esm && yarn test:cjs", | ||
"test:build": "yarn test:modules" | ||
}, | ||
"files": [ | ||
"api", | ||
"dist", | ||
"schema.json" | ||
], | ||
"dependencies": { | ||
|
@@ -52,18 +70,20 @@ | |
"@semantic-release/release-notes-generator": "9.0.2", | ||
"@tsconfig/node12": "1.0.7", | ||
"@types/jest": "26.0.23", | ||
"@types/node-fetch": "^2.5.10", | ||
"@typescript-eslint/eslint-plugin": "4.22.1", | ||
"@typescript-eslint/parser": "4.22.1", | ||
"eslint": "7.26.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"globby": "11.0.3", | ||
"jest": "26.6.3", | ||
"jest": "v27.0.0-next.8", | ||
"jest-tobetype": "1.2.3", | ||
"oas-schema-walker": "1.1.5", | ||
"prettier": "2.2.1", | ||
"semantic-release": "17.4.2", | ||
"ts-jest": "26.5.6", | ||
"ts-jest": "27.0.0-next.11", | ||
"ts-json-schema-generator": "0.92.0", | ||
"ts-node": "^9.1.1", | ||
"typescript": "4.2.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.