Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Reflect.getMetadata is not a function #20

Closed
VictorLeach96 opened this issue Jul 31, 2017 · 3 comments
Closed

Error: Reflect.getMetadata is not a function #20

VictorLeach96 opened this issue Jul 31, 2017 · 3 comments

Comments

@VictorLeach96
Copy link

VictorLeach96 commented Jul 31, 2017

I've just upgraded to the latest version of Webpack in my repo and am getting the following error, do you have any ideas what this could be?

Thanks!

/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/inversify/lib/planning/planner.js:107
            throw new Error(error.message);
                  ^
Error: Reflect.getMetadata is not a function
    at _createSubRequests (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/inversify/lib/planning/planner.js:107:19)
    at Object.plan (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/inversify/lib/planning/planner.js:126:5)
    at /Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/inversify/lib/container/container.js:239:37
    at Container._get (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/inversify/lib/container/container.js:232:44)
    at Container.get (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/inversify/lib/container/container.js:191:21)
    at e.value (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/javascript-obfuscator/dist/webpack:/src/container/InversifyContainerFacade.ts:121:34)
    at Function.value (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/javascript-obfuscator/dist/webpack:/src/JavaScriptObfuscator.ts:26:17)
    at /Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack-obfuscator/index.js:44:66
    at Array.forEach (native)
    at Compilation.<anonymous> (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack-obfuscator/index.js:22:23)
    at next (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/tapable/lib/Tapable.js:186:14)
    at Compilation.compilation.plugin (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:230:5)
    at Compilation.applyPluginsAsyncSeries (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/tapable/lib/Tapable.js:188:13)
    at self.applyPluginsAsync.err (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/Compilation.js:635:10)
    at Compilation.applyPluginsAsyncSeries (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/tapable/lib/Tapable.js:177:46)
    at sealPart2 (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/Compilation.js:631:9)
    at Compilation.applyPluginsAsyncSeries (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/tapable/lib/Tapable.js:177:46)
    at Compilation.seal (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/Compilation.js:579:8)
    at /Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/Compiler.js:493:16
    at /Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/tapable/lib/Tapable.js:271:11
    at _addModuleChain (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/Compilation.js:481:11)
    at processModuleDependencies.err (/Users/victor/Documents/Dev/Frameworks/MEAN/Test/node_modules/webpack/lib/Compilation.js:452:13)
@sanex3339
Copy link
Member

sanex3339 commented Jul 31, 2017

Please try to reproduce this error on clear webpack config without any other plugins and environments.

Because first thing that obfuscator does - requiring reflect-metadata
https://github.com/javascript-obfuscator/javascript-obfuscator/blob/master/src/JavaScriptObfuscator.ts#L1

@ezze
Copy link

ezze commented Jan 31, 2018

@sanex3339, I'm new to JavaScript obfuscator and faced the same issue trying to add your plugin 0.13.0 to my private project. Here is a list of my plugins (I append obfuscator plugin to the end of the list):

plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.DefinePlugin({
        'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
        NODE_ENV: JSON.stringify(NODE_ENV),
        VERSION: JSON.stringify(packageJson.version)
    }),
    new HtmlPlugin({
        filename: path.resolve(__dirname, 'dist/index.html'),
        inject: false,
        template: htmlTemplate,
        title: 'RIPI GeoPort',
        meta: [{
            'http-equiv': 'Cache-Control',
            content: 'no-cache, no-store, must-revalidate'
        }, {
            'http-equiv': 'Pragma',
            content: 'no-cache'
        }, {
            'http-equiv': 'Expires',
            content: '0'
        }],
        appMountId: 'container',
        scripts: ['cesium/Cesium.js'],
        minify: {
            collapseWhitespace: NODE_ENV === 'production'
        }
    }),
    new FaviconsWepbackPlugin(
        path.resolve(__dirname, 'src/favicon.png')
    ),
    new webpack.ProvidePlugin({
        'Opentip': 'opentip/lib/opentip'
    }),
    new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb|ru/),
    new webpack.optimize.CommonsChunkPlugin({
        name: 'vendor',
        minChunks: module => {
            return module.context && module.context.indexOf('node_modules') !== -1;
        }
    }),
    new webpack.optimize.CommonsChunkPlugin({
        name: 'manifest',
        minChunks: Infinity
    })
]

It's extended later by:

new ExtractTextPlugin({
    filename: 'css/[name].' + (NODE_ENV === 'development' ? '' : '[chunkhash:6].') + 'css',
    allChunks: true
}));

and

new webpack.optimize.UglifyJsPlugin({
    comments: false,
    compress: {
        warnings: false,
        drop_console: false,
        unsafe: false
    },
    sourceMap: false
});

depending on environment settings. I tried to disable some of them such as extract text, uglify, commons chunk, no emit on errors plugins but still get the same result. I can't disable all plugins because it will definitely break my build. Does it mean that obfuscator plugin is useless for me? It would be stange 'cause using listed plugins is a common use case.

@ezze
Copy link

ezze commented Jan 31, 2018

Placing obfuscator first does not change anything:

plugins: [
    new ObfuscatorPlugin(),
    ...
]

Here is stack trace:

/home/ezze/Development/geoport/node_modules/inversify/lib/planning/metadata_reader.js:8
        var compilerGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.PARAM_TYPES, constructorFunc);
                                                ^
TypeError: Reflect.getMetadata is not a function
    at MetadataReader.getConstructorMetadata (/home/ezze/Development/geoport/node_modules/inversify/lib/planning/metadata_reader.js:8:49)
    at getTargets (/home/ezze/Development/geoport/node_modules/inversify/lib/planning/reflection_utils.js:15:35)
    at Object.getDependencies (/home/ezze/Development/geoport/node_modules/inversify/lib/planning/reflection_utils.js:10:19)
    at /home/ezze/Development/geoport/node_modules/inversify/lib/planning/planner.js:106:51
    at Array.forEach (<anonymous>)
    at _createSubRequests (/home/ezze/Development/geoport/node_modules/inversify/lib/planning/planner.js:94:20)
    at Object.plan (/home/ezze/Development/geoport/node_modules/inversify/lib/planning/planner.js:129:9)
    at /home/ezze/Development/geoport/node_modules/inversify/lib/container/container.js:243:37
    at Container._get (/home/ezze/Development/geoport/node_modules/inversify/lib/container/container.js:236:44)
    at Container.get (/home/ezze/Development/geoport/node_modules/inversify/lib/container/container.js:195:21)
    at e.value (/home/ezze/Development/geoport/node_modules/javascript-obfuscator/dist/webpack:/src/container/InversifyContainerFacade.ts:126:34)
    at Function.value (/home/ezze/Development/geoport/node_modules/javascript-obfuscator/dist/webpack:/src/JavaScriptObfuscatorFacade.ts:26:17)
    at /home/ezze/Development/geoport/node_modules/webpack-obfuscator/index.js:49:66
    at Array.forEach (<anonymous>)
    at Compilation.<anonymous> (/home/ezze/Development/geoport/node_modules/webpack-obfuscator/index.js:27:23)
    at Compilation.applyPluginsAsyncSeries (/home/ezze/Development/geoport/node_modules/webpack/node_modules/tapable/lib/Tapable.js:206:13)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants