webpack-buildtime-symbols
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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

Name Type Default Description
importAlias {String} BUILDTIME_SYMBOL_TO_STRING Macro name used to decorate symbols

Package Sidebar

Install

npm i webpack-buildtime-symbols

Weekly Downloads

1

Version

0.0.4

License

ISC

Unpacked Size

8.1 kB

Total Files

5

Last publish

Collaborators

  • ximarx