Skip to content

Commit

Permalink
remove Object.entries
Browse files Browse the repository at this point in the history
  • Loading branch information
MhMadHamster committed Dec 18, 2021
1 parent 7af3dad commit e127b32
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/rules/dynamic-import-chunkname.js
Expand Up @@ -2,7 +2,7 @@ import vm from 'vm';
import docsUrl from '../docsUrl';

function generateRegexForMagicComments(magicComments) {
const preparedComments = Object.entries(magicComments).map(([comment, value]) => {
const preparedComments = magicComments.map(([comment, value]) => {
return `(${comment}: ${value})`;
});

Expand Down Expand Up @@ -36,16 +36,16 @@ module.exports = {
const config = context.options[0];
const { importFunctions = [] } = config || {};
const { webpackChunknameFormat = '([0-9a-zA-Z-_/.]|\\[(request|index)\\])+' } = config || {};
const webpackMagicComments = {
webpackChunkName: `["']${webpackChunknameFormat}["']`,
webpackPrefetch: '(true|false|-?[0-9]+)',
webpackPreload: '(true|false|-?[0-9]+)',
webpackIgnore: '(true|false)',
webpackInclude: '\\/.*\\/',
webpackExclude: '\\/.*\\/',
webpackMode: `["'](lazy|lazy-once|eager|weak)["']`,
webpackExports: `(['"]\\w+['"]|\\[(['"]\\w+['"], *)+(['"]\\w+['"]*)\\])`,
};
const webpackMagicComments = [
['webpackChunkName', `["']${webpackChunknameFormat}["']`],
['webpackPrefetch', '(true|false|-?[0-9]+)'],
['webpackPreload', '(true|false|-?[0-9]+)'],
['webpackIgnore', '(true|false)'],
['webpackInclude', '\\/.*\\/'],
['webpackExclude', '\\/.*\\/'],
['webpackMode', `["'](lazy|lazy-once|eager|weak)["']`],
['webpackExports', `(['"]\\w+['"]|\\[(['"]\\w+['"], *)+(['"]\\w+['"]*)\\])`],
];
const paddedCommentRegex = /^ (\S[\s\S]+\S) $/;
const commentStyleRegex = generateRegexForMagicComments(webpackMagicComments);
const chunkSubstrFormat = ` webpackChunkName: ["']${webpackChunknameFormat}["'],? `;
Expand Down

0 comments on commit e127b32

Please sign in to comment.