javascript - JSC_NON_GLOBAL_DEFINE_INIT_ERROR occurs when compiling js with Google Closure Compiler, webpack, and Firebase JS SDK -
jsc_non_global_define_init_error occurs when compiling js tools below:
- webpack: 3.5.6
- google closure compiler js: 20170806.0.0
- firebase js sdk: 4.3.1
environment
- macos x: 10.11.6
- node.js: v7.10.0
- npm: 4.2.0
here error message:
error in app.bundle.js:5325 (jsc_non_global_define_init_error) @define variable assignment must global
with webpack.config.js below:
module.exports = { plugins: [ new closurecompiler({ options: { languagein: 'ecmascript6', languageout: 'ecmascript3', compilationlevel: 'simple_optimizations', warninglevel: 'quiet' } }) ]
this error due @define
annotation inside firebase/utils/constants.js.
var constants = exports.constants = { /** * @define {boolean} whether client node.js sdk. */ node_client: false, /** * @define {boolean} whether admin node.js sdk. */ node_admin: false, /** * firebase sdk version */ sdk_version: '4.3.1' };
i'm not sure reason why firebase
uses @define
annotation, decided use uglifyjswebpackplugin tentative measure.
module.exports = { plugins: [ new uglifyjsplugin({ output: { comments: false } }), new closurecompiler({ options: { languagein: 'ecmascript6', languageout: 'ecmascript3', compilationlevel: 'simple_optimizations', warninglevel: 'quiet' } }) ]
fortunately uglifyjswebpackplugin seemed fix problem.
my questions are,
- does know better way solve this?
- do think there bad side-effects?
@define
annotations must global. in webpack, module , therefore not global.
best option might write custom loader strips annotation away.
Comments
Post a Comment