Skip to content

Commit 2952fa0

Browse files
committed
release: release version
1 parent 3fe1f7b commit 2952fa0

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

dist/index.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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(options = {}) {
45+
const filter = (0, _rollupPluginutils.createFilter)(
46+
options.include,
47+
options.exclude
48+
);
49+
return {
50+
transform(code, id) {
51+
if (!filter(id)) {
52+
return;
53+
} // Remove banner for JS files only
54+
55+
const ext = _path.default.extname(id).toLowerCase();
56+
57+
if (ext !== ".js" && ext !== ".jsx" && ext !== ".ts" && ext !== ".tsx") {
58+
return;
59+
}
60+
61+
const banner = (0, _extractBanner.default)(code);
62+
63+
if (!banner) {
64+
return;
65+
} // Use a magicString: it will generate the sourceMap at the end.
66+
67+
const magicString = new _magicString.default(code);
68+
const pos = code.indexOf(banner); // Remove the banner with the magicString instance.
69+
70+
magicString.remove(pos, pos + banner.length); // Trim left to remove blank spaces.
71+
72+
magicString.trimStart();
73+
return {
74+
code: magicString.toString(),
75+
map: magicString.generateMap({
76+
hires: true
77+
})
78+
};
79+
}
80+
};
81+
}
82+
83+
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.1.0",
3+
"version": "1.2.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)