Skip to content

Commit 5e88b49

Browse files
committed
release: release version
1 parent 1779812 commit 5e88b49

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

dist/index.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2016-2020 Mickael Jeanroy
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
"use strict";
26+
27+
Object.defineProperty(exports, "__esModule", {
28+
value: true
29+
});
30+
exports["default"] = rollupPluginStripBanner;
31+
32+
var _path = _interopRequireDefault(require("path"));
33+
34+
var _extractBanner = _interopRequireDefault(require("extract-banner"));
35+
36+
var _magicString = _interopRequireDefault(require("magic-string"));
37+
38+
var _rollupPluginutils = require("rollup-pluginutils");
39+
40+
function _interopRequireDefault(obj) {
41+
return obj && obj.__esModule ? obj : { default: obj };
42+
}
43+
44+
function rollupPluginStripBanner() {
45+
var options =
46+
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
47+
var filter = (0, _rollupPluginutils.createFilter)(
48+
options.include,
49+
options.exclude
50+
);
51+
return {
52+
transform: function transform(code, id) {
53+
if (!filter(id)) {
54+
return;
55+
} // Remove banner for JS files only
56+
57+
var ext = _path["default"].extname(id).toLowerCase();
58+
59+
if (ext !== ".js" && ext !== ".jsx" && ext !== ".ts" && ext !== ".tsx") {
60+
return;
61+
}
62+
63+
var banner = (0, _extractBanner["default"])(code);
64+
65+
if (!banner) {
66+
return;
67+
} // Use a magicString: it will generate the sourceMap at the end.
68+
69+
var magicString = new _magicString["default"](code);
70+
var pos = code.indexOf(banner); // Remove the banner with the magicString instance.
71+
72+
magicString.remove(pos, pos + banner.length); // Trim left to remove blank spaces.
73+
74+
magicString.trimStart();
75+
return {
76+
code: magicString.toString(),
77+
map: magicString.generateMap({
78+
hires: true
79+
})
80+
};
81+
}
82+
};
83+
}
84+
85+
module.exports = exports.default;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rollup-plugin-strip-banner",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Rollup plugin that can be used to remove banner on modules",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)