Skip to content

Commit 26852ea

Browse files
Slight Refactor of Exports to Support Externals (#246)
* Refactor export detection to create a mapping from source to exports inside a source * Tests pass now, next step is sources * External function export * More passing tests * add array and object tests * Include local name test * Prepend export {} from '' instead of append * Enforce yarn usage in pre-push * Cleanup Rollup copy not used * broken failing generator * c8 coverage * Ensure coverage folder isn't part of git history * var not let for externs since users may specify es5 with cjs * Remove dependency on sanitize filename, key is unique enough already * Revert previous commit * Add test for multiple default as exports from different sources * Can now safely remove sanitize-filename since we have a test for its previous usage
1 parent 468e68f commit 26852ea

File tree

72 files changed

+659
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+659
-387
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"scripts": {
2323
"pretest": "rimraf dist transpile && tsc -p tsconfig.test.json & wait",
2424
"test": "ava",
25-
"precoverage": "c8 ava",
25+
"precoverage": "yarn pretest && c8 ava",
2626
"coverage": "c8 report --reporter=html",
2727
"postcoverage": "sirv coverage/",
2828
"build": "rimraf dist transpile && tsc -p tsconfig.json & wait",
@@ -58,7 +58,6 @@
5858
"prettier": "1.19.1",
5959
"rimraf": "3.0.0",
6060
"rollup": "0.67.4",
61-
"rollup-plugin-copy": "3.1.0",
6261
"sirv-cli": "0.4.5",
6362
"tslint": "5.20.1",
6463
"typescript": "3.7.3"
@@ -72,7 +71,7 @@
7271
},
7372
"husky": {
7473
"hooks": {
75-
"pre-push": "npm-run-all test build",
74+
"pre-push": "yarn npm-run-all test build",
7675
"pre-commit": "lint-staged"
7776
}
7877
},

rollup.config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import pkg from './package.json';
1818
import builtins from 'builtins';
19-
import copy from 'rollup-plugin-copy';
2019

2120
export default {
2221
input: './transpile/index.js',
@@ -25,12 +24,6 @@ export default {
2524
...Object.keys(pkg.dependencies || {}),
2625
...Object.keys(pkg.peerDependencies || {}),
2726
],
28-
plugins: [
29-
copy({
30-
'./transpile/index.d.ts': './dist/index.d.ts',
31-
verbose: true,
32-
}),
33-
],
3427
output: [
3528
{
3629
file: './dist/index.mjs',

src/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const logSource = (preamble: string, source: string, code?: string) => {
2828
}
2929
};
3030

31-
export const log = (preamble: string, message: string): void | null => {
31+
export const log = (preamble: string, message: string | object): void | null => {
3232
if (DEBUG_ENABLED) {
3333
console.log(preamble);
3434
console.log(message);

src/transformers/arrow-function.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { parse, walk } from '../acorn';
2727
* @see https://astexplorer.net/#/gist/20d7fbe32292c6c9f303c1d9643885ec/6c97fabca987814cced795b8d3d078094e642264
2828
*/
2929
export default class ArrowFunctionTransform extends Transform implements TransformInterface {
30+
public name = 'ArrowFunctionTransform';
31+
3032
/**
3133
* @param code source to parse, and modify
3234
* @return modified input source with computed literal keys

src/transformers/const.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { TransformSourceDescription } from 'rollup';
2121
import MagicString from 'magic-string';
2222

2323
export default class ConstTransform extends Transform implements TransformInterface {
24+
public name = 'ConstTransform';
25+
2426
/**
2527
* When outputting ES2017+ code there is neglagible differences between `const` and `let` for runtime performance.
2628
* So, we replace all usages of `const` with `let` to enable more variable folding.

0 commit comments

Comments
 (0)