Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacksonrayhamilton/rollup-plugin-shift-header
Shift a "comment header" to the top of a bundle
https://github.com/jacksonrayhamilton/rollup-plugin-shift-header
Last synced: 25 days ago
JSON representation
Shift a "comment header" to the top of a bundle
- Host: GitHub
- URL: https://github.com/jacksonrayhamilton/rollup-plugin-shift-header
- Owner: jacksonrayhamilton
- License: mit
- Created: 2017-10-14T04:24:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-14T04:40:06.000Z (about 7 years ago)
- Last Synced: 2024-04-16T18:46:21.980Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - shift-header - Move comment headers to the top of a bundle. (Plugins / Output)
README
# rollup-plugin-shift-header
If you have a "comment header" embedded in your source code, like this:
```js
// Copyright © 2017 Jackson Ray Hamilton// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the “Software”), to deal
// ...export default function foo () {}
```Then, normally, when you generate an IIFE bundle, you'll get this:
```js
var foo = (function () {
'use strict';// Copyright © 2017 Jackson Ray Hamilton
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the “Software”), to deal
// ...function foo () {}
return foo;
}());
```It would be better if your "comment header" remained at the top of your
generated file, like this:```js
// Copyright © 2017 Jackson Ray Hamilton// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the “Software”), to deal
// ...var foo = (function () {
'use strict';function foo () {}
return foo;
}());
```This plugin ensures that a "comment header" (the first series of comments in a
file, separated by up to one empty newline) is shifted to the top of your
generated bundle.## Usage
In `rollup.config.js`, call `shiftHeader()` and add the result to your `plugins`
array:```js
import shiftHeader from 'rollup-plugin-shift-header';export default [
{
input: 'foo.mjs',
output: {
file: 'foo.js',
name: 'foo',
format: 'iife',
},
plugins: [
shiftHeader(),
],
},
];
```