Skip to content

Replacement of Number trigger error #8

@maxorlovsky

Description

@maxorlovsky

There are no error, just whole webpack breaks if you use Number as a replacement parameter.

Here is the error:

98% after emitting SizeLimitsPluginTypeError: rule.replace.bind is not a function
    at rules.reduce (/var/www/floracore-fe/node_modules/replace-in-file-webpack-plugin/index.js:28:81)
    at Array.reduce (<anonymous>)
    at replace (/var/www/floracore-fe/node_modules/replace-in-file-webpack-plugin/index.js:26:19)
    at files.forEach.file (/var/www/floracore-fe/node_modules/replace-in-file-webpack-plugin/index.js:54:7)
    at Array.forEach (<anonymous>)
    at options.forEach.option (/var/www/floracore-fe/node_modules/replace-in-file-webpack-plugin/index.js:53:12)
    at Array.forEach (<anonymous>)
    at done (/var/www/floracore-fe/node_modules/replace-in-file-webpack-plugin/index.js:46:16)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/var/www/floracore-fe/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/var/www/floracore-fe/node_modules/tapable/lib/Hook.js:35:21)
    at emitRecords.err (/var/www/floracore-fe/node_modules/webpack/lib/Compiler.js:257:22)
    at Compiler.emitRecords (/var/www/floracore-fe/node_modules/webpack/lib/Compiler.js:372:39)
    at emitAssets.err (/var/www/floracore-fe/node_modules/webpack/lib/Compiler.js:251:10)
    at hooks.afterEmit.callAsync.err (/var/www/floracore-fe/node_modules/webpack/lib/Compiler.js:358:14)
    at _err0 (eval at create (/var/www/floracore-fe/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:27:1)
    at callback (/var/www/floracore-fe/node_modules/copy-webpack-plugin/dist/index.js:126:17)
    at afterEmit (/var/www/floracore-fe/node_modules/copy-webpack-plugin/dist/index.js:220:13)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/var/www/floracore-fe/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:12:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/var/www/floracore-fe/node_modules/tapable/lib/Hook.js:35:21)
    at asyncLib.forEach.err (/var/www/floracore-fe/node_modules/webpack/lib/Compiler.js:355:27)
    at done (/var/www/floracore-fe/node_modules/neo-async/async.js:2854:11)
    at /var/www/floracore-fe/node_modules/neo-async/async.js:2805:7
    at /var/www/floracore-fe/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:139:20)
error Command failed with exit code 1.

This is the code that breaks it

template = rules.reduce(
    (template, rule) => template.replace(
        rule.search, (typeof rule.replace === 'string' ? rule.replace : rule.replace.bind(global))
    ),
    template
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions