0.0.4 • Published 25 days ago

webpack-buildtime-symbols v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
25 days ago

webpack-buildtime-symbols

Convert at built-time symbols to their string representation. Basically this plugin allows to retain the symbol name as a string after a mangling or uglification compiler pass.

Install

npm install webpack-buildtime-symbols --save-dev

or

yarn add -D webpack-buildtime-symbols

Setup

webpack.config.js

const BuildtimeSymbolsPlugin = require("webpack-buildtime-symbols/lib/plugin");
module.exports = {
  plugins: [new BuildtimeSymbolsPlugin()],
};

Usage: Webpack 4

any-file.js|ts

import {BUILDTIME_SYMBOL_TO_STRING} from "webpack-buildtime-symbols";
import {ClassName} from "another-place";

console.log("Runtime: ", BUILDTIME_SYMBOL_TO_STRING(ClassName));

After build/minification/uglification the produced result is equivalent to:

console.log("Runtime: ", "ClassName");

Usage: Webpack 5

Note: webpack 5 support is supposed but not verified. Import of BUILDTIME_SYMBOL_TO_STRING is not supported for sure right now.

any-file.js|ts

// No import for BUILDTIME_SYMBOL_TO_STRING is currently supported
import {ClassName} from "another-place";

console.log("Runtime: ", BUILDTIME_SYMBOL_TO_STRING(ClassName));

Options

NameTypeDefaultDescription
importAlias{String}BUILDTIME_SYMBOL_TO_STRINGMacro name used to decorate symbols
0.0.4

25 days ago

0.0.3

1 month ago

0.0.2

1 month ago

0.0.1

2 years ago