Skip to content

Commit

Permalink
refactor/test: move generator test to build-default
Browse files Browse the repository at this point in the history
- now that generators are supported out-of-the-box via
  polyfill-regenerator, this is no longer an integration test

- also remove @babel/plugin-transform-runtime because it's no longer
  used in tests and likely not needed much either, especially if
  babel-polyfills is recommended for other uses like core-js
  - it no longer ran either since the code was already transformed
    by polyfill-regenerator first
  • Loading branch information
agilgur5 committed Sep 20, 2020
1 parent 6e405d5 commit 2f8544d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 33 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"typescript": "^3.7.3"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.6.0",
"@types/eslint": "^6.1.2",
"@types/fs-extra": "^8.0.0",
"@types/node": "^13.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function createRollupConfig(
input: opts.input,
// Tell Rollup which packages to ignore
external: (id: string) => {
// bundle in polyfills as TSDX can't (yet) ensure installed as deps
// bundle in polyfills as TSDX can't (yet) ensure they're installed as deps
if (id.startsWith('regenerator-runtime')) {
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/fixtures/build-default/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import './syntax/optional-chaining';

import './syntax/jsx-import/JSX-import-JSX';

export { testGenerator } from './syntax/generator';

export { foo } from './foo';

export const sum = (a: number, b: number) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// regression test for generators
export function* testGenerator() {
return yield 'blah';
}
10 changes: 9 additions & 1 deletion test/e2e/tsdx-build-default.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as shell from 'shelljs';

import * as util from '../utils/fixture';
import { execWithCache } from '../utils/shell';
import { execWithCache, grep } from '../utils/shell';

shell.config.silent = false;

Expand Down Expand Up @@ -51,6 +51,14 @@ describe('tsdx build :: zero-config defaults', () => {
expect(output.code).toBe(0);
});

it('should bundle regeneratorRuntime', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);

const matched = grep(/regeneratorRuntime = r/, ['dist/build-default.*.js']);
expect(matched).toBeTruthy();
});

it('should clean the dist directory before rebuilding', () => {
let output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
Expand Down
3 changes: 0 additions & 3 deletions test/integration/fixtures/build-withBabel/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ module.exports = {
presets: [
// ensure Babel presets are merged and applied
'./test-babel-preset'
],
plugins: [
['@babel/plugin-transform-runtime', { helpers: false }],
]
}
2 changes: 0 additions & 2 deletions test/integration/fixtures/build-withBabel/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export { Title } from './styled';

export { testGenerator } from './generator';

export const sum = (a: number, b: number) => {
if ('development' === process.env.NODE_ENV) {
console.log('fuck');
Expand Down
10 changes: 0 additions & 10 deletions test/integration/tsdx-build-withBabel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ describe('integration :: tsdx build :: .babelrc.js', () => {
expect(matched).toBeFalsy();
});

it('should bundle regeneratorRuntime', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);

const matched = grep(/regeneratorRuntime = r/, [
'dist/build-withbabel.*.js',
]);
expect(matched).toBeTruthy();
});

it('should merge and apply presets', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
Expand Down
20 changes: 5 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/generator@^7.11.0", "@babel/generator@^7.11.5", "@babel/generator@^7.9.0":
"@babel/generator@^7.11.5", "@babel/generator@^7.9.0":
version "7.11.6"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.11.6.tgz#b868900f81b163b4d464ea24545c61cbac4dc620"
integrity sha512-DWtQ1PV3r+cLbySoHrwn9RWEgKMBLLma4OBQloPRyDYvc5msJM9kvTLo1YnlJd1P/ZuKbdli3ijr5q3FvAF3uA==
Expand Down Expand Up @@ -156,7 +156,7 @@
dependencies:
"@babel/types" "^7.11.0"

"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.7.4":
"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz#4c5c54be04bd31670a7382797d75b9fa2e5b5620"
integrity sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==
Expand Down Expand Up @@ -270,7 +270,7 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.0", "@babel/parser@^7.11.5", "@babel/parser@^7.7.5", "@babel/parser@^7.9.0":
"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.5", "@babel/parser@^7.7.5", "@babel/parser@^7.9.0":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.5.tgz#c7ff6303df71080ec7a4f5b8c003c58f1cf51037"
integrity sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==
Expand Down Expand Up @@ -671,16 +671,6 @@
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-transform-runtime@^7.6.0":
version "7.7.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.7.4.tgz#51fe458c1c1fa98a8b07934f4ed38b6cd62177a6"
integrity sha512-O8kSkS5fP74Ad/8pfsCMGa8sBRdLxYoSReaARRNSz3FbFQj3z/QUvoUmJ28gn9BO93YfnXc3j+Xyaqe8cKDNBQ==
dependencies:
"@babel/helper-module-imports" "^7.7.4"
"@babel/helper-plugin-utils" "^7.0.0"
resolve "^1.8.1"
semver "^5.5.1"

"@babel/plugin-transform-shorthand-properties@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.10.4.tgz#9fd25ec5cdd555bb7f473e5e6ee1c971eede4dd6"
Expand Down Expand Up @@ -7175,7 +7165,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=

[email protected], [email protected], resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
[email protected], [email protected], resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.5.0:
version "1.15.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==
Expand Down Expand Up @@ -7428,7 +7418,7 @@ semver-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338"
integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw==

"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1:
"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
Expand Down

0 comments on commit 2f8544d

Please sign in to comment.