File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 11module . exports = {
2- '.ts' : [ 'eslint --fix --cache' ] ,
3- '!(test/**/*).js' : [ 'eslint --fix --cache' ] ,
4- '{test/*,test/*/*,test/*/samples/**/_config}.js' : [ 'eslint --fix --cache' ]
2+ '*.{ts,js}' : [ 'eslint --fix --cache' ] ,
3+ '*.md' : [ 'prettier --write' ] ,
54} ;
Original file line number Diff line number Diff line change @@ -288,7 +288,27 @@ On the other hand if you are using at least Node 13 and have `"type": "module"`
288288There are some potential gotchas when using ` .mjs ` on Node 13+:
289289
290290- You will only get a default export from CommonJS plugins
291- - You may not be able to import JSON files such as your ` package.json file ` . There are two ways to go around this:
291+ - You may not be able to import JSON files such as your ` package.json file ` . There are four ways to go around this:
292+
293+ - read and parse the JSON file yourself via
294+
295+ ```
296+ // rollup.config.mjs
297+ import { readFileSync } from 'fs';
298+
299+ const packageJson = JSON.parse(readFileSync('./package.json'));
300+ ...
301+ ```
302+
303+ - use `createRequire` via
304+
305+ ```
306+ // rollup.config.mjs
307+ import { createRequire } from 'module';
308+ const require = createRequire(import.meta.url);
309+ const packageJson = require('./package.json');
310+ ...
311+ ```
292312
293313 - run Rollup CLI via
294314
You can’t perform that action at this time.
0 commit comments