diff --git a/.all-contributorsrc b/.all-contributorsrc index a96248a2b..4278d97e1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -952,6 +952,36 @@ "contributions": [ "bug" ] + }, + { + "login": "ludofischer", + "name": "Ludovico Fischer", + "avatar_url": "https://avatars1.githubusercontent.com/u/43557?v=4", + "profile": "http://www.ludofischer.com", + "contributions": [ + "code" + ] + }, + { + "login": "altrim", + "name": "Altrim Beqiri", + "avatar_url": "https://avatars0.githubusercontent.com/u/602300?v=4", + "profile": "http://www.altrimbeqiri.com", + "contributions": [ + "bug", + "code", + "test" + ] + }, + { + "login": "tanem", + "name": "Tane Morgan", + "avatar_url": "https://avatars3.githubusercontent.com/u/464864?v=4", + "profile": "https://github.com/tanem", + "contributions": [ + "bug", + "code" + ] } ], "contributorsPerLine": 7, diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..2f0479305 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at hello@formium.io. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/README.md b/README.md index f3907c338..d008aa1e6 100644 --- a/README.md +++ b/README.md @@ -653,6 +653,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Vladislav Moiseev

💻
Felix Mosheev

🐛 +
Ludovico Fischer

💻 +
Altrim Beqiri

🐛 💻 ⚠️ +
Tane Morgan

🐛 💻 diff --git a/package.json b/package.json index 7783355af..6b596eb54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsdx", - "version": "0.14.0", + "version": "0.14.1", "author": "Jared Palmer ", "description": "Zero-config TypeScript package development", "license": "MIT", @@ -68,7 +68,7 @@ "enquirer": "^2.3.4", "eslint": "^6.1.0", "eslint-config-prettier": "^6.0.0", - "eslint-config-react-app": "^5.0.2", + "eslint-config-react-app": "^5.2.1", "eslint-plugin-flowtype": "^3.13.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-jsx-a11y": "^6.2.3", @@ -89,7 +89,7 @@ "rollup": "^1.32.1", "rollup-plugin-sourcemaps": "^0.6.2", "rollup-plugin-terser": "^5.1.2", - "rollup-plugin-typescript2": "^0.26.0", + "rollup-plugin-typescript2": "^0.27.3", "sade": "^1.4.2", "semver": "^7.1.1", "shelljs": "^0.8.3", @@ -101,6 +101,7 @@ "devDependencies": { "@types/eslint": "^6.1.2", "@types/fs-extra": "^9.0.1", + "@types/lodash": "^4.14.161", "@types/node": "^14.11.1", "@types/react": "^16.9.11", "@types/rollup-plugin-json": "^3.0.2", diff --git a/src/babelPluginTsdx.ts b/src/babelPluginTsdx.ts index 525d60934..86999b600 100644 --- a/src/babelPluginTsdx.ts +++ b/src/babelPluginTsdx.ts @@ -10,7 +10,8 @@ export const isTruthy = (obj?: any) => { return obj.constructor !== Object || Object.keys(obj).length > 0; }; -const replacements = [{ original: 'lodash', replacement: 'lodash-es' }]; +// replace lodash with lodash-es, but not lodash/fp +const replacements = [{ original: 'lodash(?!/fp)', replacement: 'lodash-es' }]; export const mergeConfigItems = (type: any, ...configItemsToMerge: any[]) => { const mergedItems: any[] = []; diff --git a/test/e2e/fixtures/build-default/src/index.ts b/test/e2e/fixtures/build-default/src/index.ts index 308bd9487..ca8751686 100644 --- a/test/e2e/fixtures/build-default/src/index.ts +++ b/test/e2e/fixtures/build-default/src/index.ts @@ -6,6 +6,9 @@ import './syntax/jsx-import/JSX-import-JSX'; import './syntax/async'; export { testGenerator } from './syntax/generator'; +export { kebabCase } from 'lodash'; +export { merge, mergeAll } from 'lodash/fp'; + export { foo } from './foo'; export const sum = (a: number, b: number) => { diff --git a/test/e2e/tsdx-build-default.test.ts b/test/e2e/tsdx-build-default.test.ts index f2d4c6618..1f88d1ab1 100644 --- a/test/e2e/tsdx-build-default.test.ts +++ b/test/e2e/tsdx-build-default.test.ts @@ -67,6 +67,30 @@ describe('tsdx build :: zero-config defaults', () => { expect(matched).toBeFalsy(); }); + it('should use lodash for the CJS build', () => { + const output = execWithCache('node ../dist/index.js build'); + expect(output.code).toBe(0); + + const matched = grep(/lodash/, ['dist/build-default.cjs.*.js']); + expect(matched).toBeTruthy(); + }); + + it('should use lodash-es for the ESM build', () => { + const output = execWithCache('node ../dist/index.js build'); + expect(output.code).toBe(0); + + const matched = grep(/lodash-es/, ['dist/build-default.esm.js']); + expect(matched).toBeTruthy(); + }); + + it("shouldn't replace lodash/fp", () => { + const output = execWithCache('node ../dist/index.js build'); + expect(output.code).toBe(0); + + const matched = grep(/lodash\/fp/, ['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); diff --git a/test/e2e/tsdx-build-options.test.ts b/test/e2e/tsdx-build-options.test.ts new file mode 100644 index 000000000..ded530033 --- /dev/null +++ b/test/e2e/tsdx-build-options.test.ts @@ -0,0 +1,53 @@ +import * as shell from 'shelljs'; + +import * as util from '../utils/fixture'; +import { execWithCache } from '../utils/shell'; + +shell.config.silent = false; + +const testDir = 'e2e'; +const fixtureName = 'build-default'; +// create a second version of build-default's stage for concurrent testing +const stageName = 'stage-build-options'; + +describe('tsdx build :: options', () => { + beforeAll(() => { + util.teardownStage(stageName); + util.setupStageWithFixture(testDir, stageName, fixtureName); + }); + + it('should compile all formats', () => { + const output = execWithCache( + 'node ../dist/index.js build --format cjs,esm,umd,system' + ); + + expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-default.cjs.development.js') + ).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-default.cjs.production.min.js') + ).toBeTruthy(); + expect(shell.test('-f', 'dist/build-default.esm.js')).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-default.umd.development.js') + ).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-default.umd.production.min.js') + ).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-default.system.development.js') + ).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-default.system.production.min.js') + ).toBeTruthy(); + + expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); + + expect(output.code).toBe(0); + }); + + afterAll(() => { + util.teardownStage(stageName); + }); +}); diff --git a/yarn.lock b/yarn.lock index 7814dee49..29a9e1e09 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1314,6 +1314,11 @@ dependencies: "@types/node" "*" +"@types/lodash@^4.14.161": + version "4.14.161" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.161.tgz#a21ca0777dabc6e4f44f3d07f37b765f54188b18" + integrity sha512-EP6O3Jkr7bXvZZSZYlsgt5DIjiGr0dXP1/jVEwVLTFgg0d+3lWVQkRavYVQszV7dYUwvg0B8R0MBDpcmXg7XIA== + "@types/minimatch@*", "@types/minimatch@^3.0.3": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" @@ -3121,10 +3126,10 @@ eslint-config-prettier@^6.0.0: dependencies: get-stdin "^6.0.0" -eslint-config-react-app@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-5.0.2.tgz#df40d73a1402986030680c040bbee520db5a32a4" - integrity sha512-VhlESAQM83uULJ9jsvcKxx2Ab0yrmjUt8kDz5DyhTQufqWE0ssAnejlWri5LXv25xoXfdqOyeDPdfJS9dXKagQ== +eslint-config-react-app@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-5.2.1.tgz#698bf7aeee27f0cea0139eaef261c7bf7dd623df" + integrity sha512-pGIZ8t0mFLcV+6ZirRgYK6RVqUIKRIi9MmgzUEmrIknsn3AdO0I32asO86dJgloHq+9ZPl8UIg8mYrvgP5u2wQ== dependencies: confusing-browser-globals "^1.0.9" @@ -3554,13 +3559,13 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" -find-cache-dir@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.2.0.tgz#e7fe44c1abc1299f516146e563108fd1006c1874" - integrity sha512-1JKclkYYsf1q9WIJKLZa9S9muC+08RIjzAlLrK4QcYLJMS6mk9yombQ9qf+zJ7H9LS800k0s44L4sDq9VYzqyg== +find-cache-dir@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" + integrity sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== dependencies: commondir "^1.0.1" - make-dir "^3.0.0" + make-dir "^3.0.2" pkg-dir "^4.1.0" find-up@^2.0.0, find-up@^2.1.0: @@ -5407,10 +5412,10 @@ magic-string@^0.25.2: dependencies: sourcemap-codec "^1.4.4" -make-dir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.0.tgz#1b5f39f6b9270ed33f9f054c5c0f84304989f801" - integrity sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw== +make-dir@^3.0.0, make-dir@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" + integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== dependencies: semver "^6.0.0" @@ -7100,14 +7105,7 @@ resolve@1.1.7: resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= -resolve@1.15.1: - version "1.15.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" - integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w== - dependencies: - path-parse "^1.0.6" - -resolve@1.x, 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.17.0, resolve@^1.3.2, resolve@^1.5.0: +resolve@1.17.0, resolve@1.x, 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.17.0, resolve@^1.3.2, resolve@^1.5.0: version "1.17.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== @@ -7212,18 +7210,18 @@ rollup-plugin-terser@^5.1.2: serialize-javascript "^1.7.0" terser "^4.1.0" -rollup-plugin-typescript2@^0.26.0: - version "0.26.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.26.0.tgz#cee2b44d51d9623686656d76dc30a73c4de91672" - integrity sha512-lUK7XZVG77tu8dmv1L/0LZFlavED/5Yo6e4iMMl6fdox/yKdj4IFRRPPJEXNdmEaT1nDQQeCi7b5IwKHffMNeg== +rollup-plugin-typescript2@^0.27.3: + version "0.27.3" + resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.27.3.tgz#cd9455ac026d325b20c5728d2cc54a08a771b68b" + integrity sha512-gmYPIFmALj9D3Ga1ZbTZAKTXq1JKlTQBtj299DXhqYz9cL3g/AQfUvbb2UhH+Nf++cCq941W2Mv7UcrcgLzJJg== dependencies: - find-cache-dir "^3.2.0" + "@rollup/pluginutils" "^3.1.0" + find-cache-dir "^3.3.1" fs-extra "8.1.0" - resolve "1.15.1" - rollup-pluginutils "2.8.2" - tslib "1.10.0" + resolve "1.17.0" + tslib "2.0.1" -rollup-pluginutils@2.8.2, rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.6.0, rollup-pluginutils@^2.8.1: +rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.6.0, rollup-pluginutils@^2.8.1: version "2.8.2" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== @@ -8088,7 +8086,12 @@ ts-jest@^25.3.1: semver "6.x" yargs-parser "18.x" -tslib@1.10.0, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: +tslib@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" + integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== + +tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==