Skip to content

Commit

Permalink
Revert "fix: correct declaration output dir (#627)"
Browse files Browse the repository at this point in the history
This reverts commit d175973.
  • Loading branch information
guybedford committed Jan 11, 2021
1 parent 9ff73a0 commit b30e105
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 230 deletions.
23 changes: 7 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -51,7 +51,7 @@ function ncc (
debugLog = false,
transpileOnly = false,
license = '',
target,
target
} = {}
) {
process.env.__NCC_OPTS = JSON.stringify({
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/unit/ts-decl-dir/input.js

This file was deleted.

101 changes: 0 additions & 101 deletions test/unit/ts-decl-dir/output-coverage.js

This file was deleted.

101 changes: 0 additions & 101 deletions test/unit/ts-decl-dir/output.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/unit/ts-decl-dir/test.ts

This file was deleted.

8 changes: 0 additions & 8 deletions test/unit/ts-decl-dir/tsconfig.json

This file was deleted.

0 comments on commit b30e105

Please sign in to comment.