Prepend a directive to the top of a file
npm install prepend-directivePrepend a directive to the top of a file.
Useful as a post build script if your build tool (e.g. microbundle) strips comments and does not allow you to configure the behavior conditionally.
``shell`
npx prepend-directive@latest --directive=\"use strict\" --files=file-a.js,file-b.js
`jsprepend-directive
const prependDirective = require();
prependDirective({
directive: use strict,file-a.js
files: [, file-b.js],`
cwd: __dirname, // Optional
});
file-a.js:
`jsa
const a = () => ;`
file-b.js:
`jsb
const b = () => ;`
file-a.js:
`jsa
"use strict"
const a = () => ;`
file-b.js:
`jsb
"use strict"
const b = () => ;``