Skip to content

feat: allow to ignore modules from processing #287

Merged
satya164 merged 1 commit intomasterfrom
@satya164/exclude-node-modules
Jan 5, 2019
Merged

feat: allow to ignore modules from processing #287
satya164 merged 1 commit intomasterfrom
@satya164/exclude-node-modules

Conversation

@satya164
Copy link
Copy Markdown
Member

@satya164 satya164 commented Jan 5, 2019

Transpiling a large number of files can cause significant slowdowns, especially visible when transforming files under /node_modules/.
This excludes /node_modules/ by default and adds a config option to customize which files to exclude.

As a next step, we should also cache the files we transpile in-memory to optimize it further.

Fixes #286

@callstack-bot
Copy link
Copy Markdown

callstack-bot commented Jan 5, 2019

Hey @satya164, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@satya164 satya164 force-pushed the @satya164/exclude-node-modules branch 2 times, most recently from f404938 to 882a588 Compare January 5, 2019 11:54
Comment thread docs/BABEL_PRESET.md Outdated

* `evaluate: boolean` (default: `true`) - Enabling this will evaluate dynamic expressions in the CSS. You need to enable this if you want to use imported variables in the CSS or interpolate other components. Enabling this also ensures that your styled components wrapping other styled components will have the correct specificity and override styles properly.
* `displayName: boolean` (default: `false`) - Enabling this will add a display name to generated class names, e.g. `.Title_abcdef` instead of `.abcdef'. It is disabled by default to generate smaller CSS files.
* `exclude: RegExp` (default: `/node_modules/`) - If you specify a regex here, files matching the regex won't be processed, i.e. the matching files won't be transformed with Babel during evaluation. If you need to transpile certain modules under `/node_modules/`, it's recommended to do it on a module by module basis for faster transforms, e.g. `exclude: /node_modules(?!.*[\/\\](some-module))/`.
Copy link
Copy Markdown
Member

@thymikee thymikee Jan 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this regex to be simpler: node_modules[\/\\](?!some-module|other-module).

Btw, how about using globs? They're generally less confusing than regular expressions and Babel supports them (to some extent at least)
EDIT: pardon, I forgot we don't use Babel resolution here, so we'd have to import glob library, which are painful to work with (different glob syntaxes with different versions and Windows issues)

Comment thread src/transform.js Outdated
@satya164 satya164 force-pushed the @satya164/exclude-node-modules branch from 882a588 to 23ff918 Compare January 5, 2019 12:50
@satya164 satya164 changed the title feat: allow to exclude modules from processing feat: allow to ignore modules from processing Jan 5, 2019
@satya164
Copy link
Copy Markdown
Member Author

satya164 commented Jan 5, 2019

@thymikee updated the PR. had to rename exclude to ignore to avoid conflict with the exclude option in the rollup plugin.

@thymikee
Copy link
Copy Markdown
Member

thymikee commented Jan 5, 2019

👍

@satya164 satya164 force-pushed the @satya164/exclude-node-modules branch from 23ff918 to d38a444 Compare January 5, 2019 14:02
Comment thread src/babel/extract.js Outdated
options = {
displayName: false,
evaluate: true,
exclude: /node_modules/,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default ignore is missing

Transpiling a large number of files can cause significant slowdowns, especially visible when transforming files under `/node_modules/`.
This ignores `/node_modules/` by default and adds a config option to customize which files to ignore.

As a next step, we should also cache the files we transpile in-memory to optimize it further.

Fixes #286
@satya164 satya164 force-pushed the @satya164/exclude-node-modules branch from d38a444 to f1ac80a Compare January 5, 2019 19:53
@satya164 satya164 merged commit 94d77c0 into master Jan 5, 2019
@satya164 satya164 deleted the @satya164/exclude-node-modules branch January 5, 2019 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants