Skip to content

Commit

Permalink
fix(web): preserve the target set in tsconfig.lib.json
Browse files Browse the repository at this point in the history
ISSUES CLOSED: nrwl#3601
  • Loading branch information
mandarini committed Sep 4, 2020
1 parent 694aa0c commit 0949ed0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
35 changes: 31 additions & 4 deletions e2e/react/src/react-package.test.ts
Expand Up @@ -104,18 +104,45 @@ forEachCli('nx', (cli) => {
runCLI(
`generate @nrwl/react:library ${myLib} --publishable --no-interactive`
);

/**
*
* Here I would update my library file
*
* updateFile(`libs/${myLib}/src/lib/${myLib}.tsx`, (content) => {
*
* Not sure how, will find how.
*
* })
*
* I would just add this in the end:
*
* export const TestFunction = async () => {
* return await Promise.resolve('Done!')
* }
*
*/

updateFile(`libs/${myLib}/tsconfig.json`, (content) => {
const json = JSON.parse(content);
json.compilerOptions.target = 'ES2020';

/**
* Set target as es3!!
*/

json.compilerOptions.target = 'es3';
return JSON.stringify(json, null, 2);
});
// What we're testing
runCLI(`build ${myLib}`);
// Assertion
const content = readFile(`dist/libs/${myLib}/${myLib}.esm.js`);
// ???? Need to figure out what to match on based on tsconfig target
// Need to check that the bundle preserves what we expect from es2020
expect(content).toMatch(/import React/);

/**
* Then check if the result contains this "promise" polyfill?
*/

expect(content).toContain('function __generator(thisArg, body) {');
});

it('should build the library when it does not have any deps', () => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@nrwl/nx-source",
"version": "10.1.0",
"version": "999.8.3",
"description": "Extensible Dev Tools for Monorepos",
"homepage": "https://nx.dev",
"main": "index.js",
Expand Down Expand Up @@ -249,4 +249,4 @@
"pre-push": "yarn checkcommit && yarn documentation && pretty-quick --check"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/web/src/builders/package/package.impl.ts
Expand Up @@ -120,7 +120,7 @@ export function run(
return () => watcher.close();
});
} else {
context.logger.info('Bundling...');
context.logger.info(`Bundling...`);

// Delete output path before bundling
deleteOutputDir(context.workspaceRoot, options.outputPath);
Expand Down

0 comments on commit 0949ed0

Please sign in to comment.