Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ function ncc (
module: 'esnext',
target: 'esnext',
...fullTsconfig.compilerOptions,
// ncc bundles the root project and its dependencies as one compilation.
// Disable composite's implicit rootDir so referenced sources are included.
composite: false,
allowSyntheticDefaultImports: true,
noEmit: false,
outDir: '//'
Expand Down
10 changes: 6 additions & 4 deletions test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ for (const unitTest of fs.readdirSync(`${__dirname}/unit`)) {
opts = JSON.parse(opts);
} catch (_) {}

// set env variable so tsconfig-paths can find the config
process.env.TS_NODE_PROJECT = `${testDir}/tsconfig.json`;
// find the name of the input file (e.g input.ts)
const inputFile = fs.readdirSync(testDir).find(file => file.includes("input"));
await ncc(`${testDir}/${inputFile}`, Object.assign({
const rootInput = fs.readdirSync(testDir).find(file => file.includes("input"));
const inputDir = rootInput ? testDir : `${testDir}/app`;
const inputFile = rootInput || fs.readdirSync(inputDir).find(file => file.includes("input"));
// set env variable so tsconfig-paths can find the config
process.env.TS_NODE_PROJECT = `${inputDir}/tsconfig.json`;
await ncc(`${inputDir}/${inputFile}`, Object.assign({
assetBuilds: true,
transpileOnly: true,
customEmit (path) {
Expand Down
3 changes: 3 additions & 0 deletions test/unit/ts-project-references/app/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { hello } from '../lib/index';

console.log(hello());
12 changes: 12 additions & 0 deletions test/unit/ts-project-references/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"composite": true,
"outDir": "dist"
},
"include": ["input.ts"],
"references": [
{
"path": "../lib"
}
]
}
3 changes: 3 additions & 0 deletions test/unit/ts-project-references/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function hello() {
return 'Hello, World!';
}
6 changes: 6 additions & 0 deletions test/unit/ts-project-references/lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"composite": true,
"outDir": "dist"
}
}
4 changes: 4 additions & 0 deletions test/unit/ts-project-references/opt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cache": false,
"transpileOnly": false
}
21 changes: 21 additions & 0 deletions test/unit/ts-project-references/output-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};

;// CONCATENATED MODULE: ./test/unit/ts-project-references/lib/index.ts
function hello() {
return 'Hello, World!';
}

;// CONCATENATED MODULE: ./test/unit/ts-project-references/app/input.ts

console.log(hello());

module.exports = __webpack_exports__;
/******/ })()
;
21 changes: 21 additions & 0 deletions test/unit/ts-project-references/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};

;// CONCATENATED MODULE: ./test/unit/ts-project-references/lib/index.ts
function hello() {
return 'Hello, World!';
}

;// CONCATENATED MODULE: ./test/unit/ts-project-references/app/input.ts

console.log(hello());

module.exports = __webpack_exports__;
/******/ })()
;