From b30e1051117e2a03ed8b6f2d123c9ee41ad82305 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 11 Jan 2021 12:48:35 -0500 Subject: [PATCH] Revert "fix: correct declaration output dir (#627)" This reverts commit d175973dd11b88f6fce5df7ce1a20b6e82b619ca. --- src/index.js | 23 ++---- test/unit/ts-decl-dir/input.js | 1 - test/unit/ts-decl-dir/output-coverage.js | 101 ----------------------- test/unit/ts-decl-dir/output.js | 101 ----------------------- test/unit/ts-decl-dir/test.ts | 3 - test/unit/ts-decl-dir/tsconfig.json | 8 -- 6 files changed, 7 insertions(+), 230 deletions(-) delete mode 100644 test/unit/ts-decl-dir/input.js delete mode 100644 test/unit/ts-decl-dir/output-coverage.js delete mode 100644 test/unit/ts-decl-dir/output.js delete mode 100644 test/unit/ts-decl-dir/test.ts delete mode 100644 test/unit/ts-decl-dir/tsconfig.json diff --git a/src/index.js b/src/index.js index 5ea3f6bb..2a9be4c2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ const resolve = require("resolve"); const fs = require("graceful-fs"); const crypto = require("crypto"); -const { join, dirname, extname, relative, resolve: pathResolve } = require("path"); +const { join, dirname, extname, relative } = require("path"); const webpack = require("webpack"); const MemoryFS = require("memory-fs"); const terser = require("terser"); @@ -51,7 +51,7 @@ function ncc ( debugLog = false, transpileOnly = false, license = '', - target, + target } = {} ) { process.env.__NCC_OPTS = JSON.stringify({ @@ -86,12 +86,9 @@ function ncc ( // add TsconfigPathsPlugin to support `paths` resolution in tsconfig // we need to catch here because the plugin will // error if there's no tsconfig in the working directory - let fullTsconfig; try { const tsconfig = tsconfigPaths.loadConfig(); - fullTsconfig = loadTsconfig(tsconfig.configFileAbsolutePath) || { - compilerOptions: {} - }; + const fullTsconfig = loadTsconfig(tsconfig.configFileAbsolutePath) const tsconfigPathsOptions = { silent: true } if (fullTsconfig.compilerOptions.allowJs) { @@ -356,7 +353,7 @@ function ncc ( async function finalizeHandler (stats) { const assets = Object.create(null); - getFlatFiles(mfs.data, assets, relocateLoader.getAssetMeta, fullTsconfig); + getFlatFiles(mfs.data, assets, relocateLoader.getAssetMeta); // filter symlinks to existing assets const symlinks = Object.create(null); for (const [key, value] of Object.entries(relocateLoader.getSymlinks())) { @@ -516,21 +513,15 @@ function ncc ( } // this could be rewritten with actual FS apis / globs, but this is simpler -function getFlatFiles(mfsData, output, getAssetMeta, tsconfig, curBase = "") { +function getFlatFiles(mfsData, output, getAssetMeta, curBase = "") { for (const path of Object.keys(mfsData)) { const item = mfsData[path]; - let curPath = `${curBase}/${path}`; + const curPath = `${curBase}/${path}`; // directory - if (item[""] === true) getFlatFiles(item, output, getAssetMeta, tsconfig, curPath); + if (item[""] === true) getFlatFiles(item, output, getAssetMeta, curPath); // file else if (!curPath.endsWith("/")) { const meta = getAssetMeta(curPath.substr(1)) || {}; - if(curPath.endsWith(".d.ts")) { - const outDir = tsconfig.compilerOptions.outDir ? pathResolve(tsconfig.compilerOptions.outDir) : pathResolve('dist'); - curPath = curPath - .replace(outDir, "") - .replace(process.cwd(), "") - } output[curPath.substr(1)] = { source: mfsData[path], permissions: meta.permissions diff --git a/test/unit/ts-decl-dir/input.js b/test/unit/ts-decl-dir/input.js deleted file mode 100644 index 40caa795..00000000 --- a/test/unit/ts-decl-dir/input.js +++ /dev/null @@ -1 +0,0 @@ -export * from './test.ts'; diff --git a/test/unit/ts-decl-dir/output-coverage.js b/test/unit/ts-decl-dir/output-coverage.js deleted file mode 100644 index d505120f..00000000 --- a/test/unit/ts-decl-dir/output-coverage.js +++ /dev/null @@ -1,101 +0,0 @@ -module.exports = -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ 676: -/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { - -__nccwpck_require__.r(__webpack_exports__); -/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { -/* harmony export */ "__esModule": () => /* reexport safe */ _test_ts__WEBPACK_IMPORTED_MODULE_0__.X, -/* harmony export */ "test": () => /* reexport safe */ _test_ts__WEBPACK_IMPORTED_MODULE_0__.B -/* harmony export */ }); -/* harmony import */ var _test_ts__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(867); - - - -/***/ }), - -/***/ 867: -/***/ ((__unused_webpack_module, exports) => { - - -exports.X = true; -function test(arg) { - return arg; -} -exports.B = test; - - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __nccwpck_require__(moduleId) { -/******/ // Check if module is in cache -/******/ if(__webpack_module_cache__[moduleId]) { -/******/ return __webpack_module_cache__[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ var threw = true; -/******/ try { -/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__); -/******/ threw = false; -/******/ } finally { -/******/ if(threw) delete __webpack_module_cache__[moduleId]; -/******/ } -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __nccwpck_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __nccwpck_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __nccwpck_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/compat */ -/******/ -/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/ -/******/ // module exports must be returned from runtime so entry inlining is disabled -/******/ // startup -/******/ // Load entry module and return exports -/******/ return __nccwpck_require__(676); -/******/ })() -; \ No newline at end of file diff --git a/test/unit/ts-decl-dir/output.js b/test/unit/ts-decl-dir/output.js deleted file mode 100644 index 93e65287..00000000 --- a/test/unit/ts-decl-dir/output.js +++ /dev/null @@ -1,101 +0,0 @@ -module.exports = -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ 345: -/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { - -__nccwpck_require__.r(__webpack_exports__); -/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { -/* harmony export */ "__esModule": () => /* reexport safe */ _test_ts__WEBPACK_IMPORTED_MODULE_0__.X, -/* harmony export */ "test": () => /* reexport safe */ _test_ts__WEBPACK_IMPORTED_MODULE_0__.B -/* harmony export */ }); -/* harmony import */ var _test_ts__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(57); - - - -/***/ }), - -/***/ 57: -/***/ ((__unused_webpack_module, exports) => { - - -exports.X = true; -function test(arg) { - return arg; -} -exports.B = test; - - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __nccwpck_require__(moduleId) { -/******/ // Check if module is in cache -/******/ if(__webpack_module_cache__[moduleId]) { -/******/ return __webpack_module_cache__[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ var threw = true; -/******/ try { -/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__); -/******/ threw = false; -/******/ } finally { -/******/ if(threw) delete __webpack_module_cache__[moduleId]; -/******/ } -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __nccwpck_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __nccwpck_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __nccwpck_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/compat */ -/******/ -/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/ -/******/ // module exports must be returned from runtime so entry inlining is disabled -/******/ // startup -/******/ // Load entry module and return exports -/******/ return __nccwpck_require__(345); -/******/ })() -; \ No newline at end of file diff --git a/test/unit/ts-decl-dir/test.ts b/test/unit/ts-decl-dir/test.ts deleted file mode 100644 index 5436fc69..00000000 --- a/test/unit/ts-decl-dir/test.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function test (arg: string): string { - return arg; -} \ No newline at end of file diff --git a/test/unit/ts-decl-dir/tsconfig.json b/test/unit/ts-decl-dir/tsconfig.json deleted file mode 100644 index 2a668ec3..00000000 --- a/test/unit/ts-decl-dir/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "outDir": "dist", - "declaration": true, - "declarationDir": "dist/types" - } -} \ No newline at end of file