diff --git a/badges.svg b/badges.svg index d7a99220..4354a36c 100644 --- a/badges.svg +++ b/badges.svg @@ -1,23 +1,20 @@ - - \ No newline at end of file diff --git a/index.html b/index.html index 01a76b34..8d374de9 100644 --- a/index.html +++ b/index.html @@ -6,38 +6,115 @@ - - -
-Modular import plugin for babel for server-side rendering. Also works for cjs to delete imported CSS to avoid compilation errors..
-npm install babel-plugin-transform-remove-imports --save-dev -
+ + babel-plugin-transform-remove-imports +
Modular import plugin for babel for server-side rendering. Also works for cjs to delete imported CSS to avoid compilation errors..
++ Usage
-npm install babel-plugin-transform-remove-imports --save-dev +
Via
-.babelrc
orbabel-loader
.{ - "plugins": [ - [ - "babel-plugin-transform-remove-imports", { - "test": "\\.(less|css)$" - } - ] - ] -} -
{ + "plugins": [ + [ + "babel-plugin-transform-remove-imports", { + "test": "\\.(less|css)$" + } + ] + ] +} +
-// Input Code -import './index.less'; -import './index.main.less'; -import { Button } from 'uiw'; -import { Select } from '@uiw/core'; - -// Output β β β β β β -import { Button } from 'uiw'; -import { Select } from '@uiw/core'; -
// Input Code +import './index.less'; +import './index.main.less'; +import { Button } from 'uiw'; +import { Select } from '@uiw/core'; + +// Output β β β β β β +import { Button } from 'uiw'; +import { Select } from '@uiw/core'; +
-Output Result
-- import './index.less'; -- import './index.main.less'; -import { Button } from 'uiw'; -import { Select } from '@uiw/core'; -
- import './index.less'; +- import './index.main.less'; +import { Button } from 'uiw'; +import { Select } from '@uiw/core'; +
-- Support
require
Via
-.babelrc
orbabel-loader
.{ - "plugins": [ - [ - "babel-plugin-transform-remove-imports", { - "test": "@babel/core", - } - ] - ] -} -
Supportrequire
+Via
+.babelrc
orbabel-loader
.-{ + "plugins": [ + [ + "babel-plugin-transform-remove-imports", { + "test": "@babel/core", + } + ] + ] +} +
// Input Code -require('@babel/core'); -const jest = require('jest'); - -// Output β β β β β β -var jest = require('jest'); -
// Input Code +require('@babel/core'); +const jest = require('jest'); + +// Output β β β β β β +var jest = require('jest'); +
-Output Result
-- require('@babel/core'); -- const jest = require('jest'); -+ var jest = require('jest'); -
- require('@babel/core'); +- const jest = require('jest'); ++ var jest = require('jest'); +
-- Options
-
-- -
test: RegExp | string | (RegExp | string)[]
- A regular expression to match the imports that will be removed. - It could be a string or a RegExp object. - You could also pass an array here. -
--
-- -
removeAll: boolean
Deletes all imports.
--
-- -
remove?: 'effects'
Removing only side effects importsοΌUsed with the
-test
option. #3// Input Code -import 'foo'; -import Foo from 'foo'; - -// Output Code β β β β β β -import Foo from 'foo'; -
Options ++
+- +
test: RegExp | string | (RegExp | string)[]
+ A regular expression to match the imports that will be removed. + It could be a string or a RegExp object. + You could also pass an array here. +
++
+- +
removeAll: boolean
Deletes all imports.
++
+- +
remove?: 'effects'
Removing only side effects importsοΌUsed with the
+test
option. #3-// Input Code +import 'foo'; +import Foo from 'foo'; + +// Output Code β β β β β β +import Foo from 'foo'; +
- Programmatic Usage
import plugin from 'babel-plugin-transform-remove-imports' -import { transform } from 'babel-core' - -function replace (code) { - return transform(code, { - babelrc: false, - plugins: [ - [plugin, { test: /\.(less|css)$/ }] - ], - }).code; -} - -replace("import './index.main.less';import { Button } from 'uiw';") -//=> "import { Button } from 'uiw';" -
- + Programmatic Usage +-import plugin from 'babel-plugin-transform-remove-imports' +import { transform } from 'babel-core' + +function replace (code) { + return transform(code, { + babelrc: false, + plugins: [ + [plugin, { test: /\.(less|css)$/ }] + ], + }).code; +} + +replace("import './index.main.less';import { Button } from 'uiw';") +//=> "import { Button } from 'uiw';" +
- Contributors
As always, thanks to our amazing contributors!
-Made with github-action-contributors.
-- License
MIT Β©
- - -Kenny Wong
&Slava Fomin II
+ Contributors
As always, thanks to our amazing contributors!
+Made with github-action-contributors.
++ License
MIT Β©
+Kenny Wong
&Slava Fomin II