standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.27k stars 147 forks source link

Loading .yaml file doesn't work #892

Open kopkaa opened 4 years ago

kopkaa commented 4 years ago
Summary
Issue Type
OS / ENVIRONMENT
System:
    OS: Linux 5.7 Fedora 32 (Workstation Edition) 32 (Workstation Edition)
    CPU: (2) x64 Intel(R) Pentium(R) CPU G630 @ 2.70GHz
    Memory: 816.25 MB / 11.41 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 12.18.3 - /usr/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.6 - /usr/bin/npm
  Managers:
    pip3: 19.3.1 - /usr/bin/pip3
    Yum: 4.2.23 - /usr/bin/yum
  Utilities:
    Make: 4.2.1 - /usr/bin/make
    GCC: 10.2.1 - /usr/bin/gcc
    Git: 2.26.2 - /usr/bin/git
  Browsers:
    Chrome: 84.0.4147.89
Desired Behaviour

I want to load ".yaml" config using argv module in my TypeScript project. This is my package.json. I use dev script to start program. I start it like yarn dev -c config.yaml

{
  "name": "db2mail",
  "version": "1.4.0",
  "description": "",
  "main": "db2mail.js",
  "license": "ISC",
  "scripts": {
    "clean": "rimraf lib coverage",
    "test": "jest",
    "test:watch": "jest --watch",
    "prettier": "pretty-quick",
    "prettier:staged": "pretty-quick --staged",
    "dev": "npm run clean && cross-env NODE_PATH=./ DEBUG=DB2MAIL:* NODE_ENV=development backpack dev",
    "start": "npm run build && DEBUG=DB2MAIL:*  node lib/main.js",
    "build": "cross-env DEBUG=BUILD:* NODE_ENV=production backpack build -p"
  },
  "jest": {
    "transform": {
      ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "yaml"
    ],
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "/test/"
    ],
    "coverageThreshold": {
      "global": {
        "branches": 50,
        "functions": 50,
        "lines": 50,
        "statements": 50
      }
    },
    "collectCoverage": true
  },
  "dependencies": {
    "debug": "^3.1.0",
    "email-templates": "5.1.0",
    "js-yaml": "^3.14.0",
    "lbasync": "https://git.linuxbox.cz/nodejs-modules/lbasync.git#new-syslogger",
    "nodemailer": "2.6.4",
    "nodemailer-sendmail-transport": "1.0.0",
    "nunjucks": "^3.2.2",
    "yargs": "^16.1.0"
  },
  "devDependencies": {
    "@types/bluebird": "^3.5.21",
    "@types/debug": "^0.0.30",
    "@types/jest": "^23.1.4",
    "@types/node": "^10.5.1",
    "babel-minify-webpack-plugin": "0.3.0",
    "babel-preset-env": "^1.7.0",
    "backpack-core": "^0.7.0",
    "cross-env": "^5.2.0",
    "husky": "^0.14.3",
    "jest": "22.4.4",
    "lerna": "^2.11.0",
    "prettier": "^1.13.7",
    "pretty-quick": "^1.6.0",
    "rimraf": "^2.6.2",
    "ts-jest": "^23.0.0",
    "ts-loader": "3.5.0",
    "tslint": "^5.10.0",
    "tslint-config-airbnb": "^5.9.2",
    "typescript": "^2.9.2",
    "uglifyjs-webpack-plugin": "^1.2.7"
  },
  "resolutions": {
    "@ladjs/i18n": "1.1.0"
  }
}
Actual Behaviour

Instead of loading my ".yaml" file I got this error:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".yaml"
    at defaultGetFormat (internal/modules/esm/get_format.js:65:15)
    at checkSyntax (internal/main/check_syntax.js:57:24)
    at internal/main/check_syntax.js:39:3 {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'