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

DedupePlugin fails: No template for dependency: TemplateArgumentDependency #1082

Closed
alansouzati opened this issue May 19, 2015 · 24 comments · Fixed by FormidableLabs/formidable-playbook-docs#8
Labels

Comments

@alansouzati
Copy link

Hi folks,

Great job with Webpack, this framework is really helping my project to succeed. I'm using version 1.8.11 through gulp-webpack and after I've added react-intl in my project this problem started to happen:

Error: No template for dependency: TemplateArgumentDependency
    at doDep (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/NormalModule.js:116:23)
    at Array.forEach (native)
    at doBlock (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/NormalModule.js:125:22)
    at DependenciesBlock.NormalModule.source (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/NormalModule.js:159:2)
    at Tapable.ModuleTemplate.render (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/ModuleTemplate.js:14:28)
    at Tapable.Template.renderChunkModules (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/Template.js:80:31)
    at Tapable.<anonymous> (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/MainTemplate.js:28:22)
    at Tapable.applyPlugins [as applyPluginsWaterfall] (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/node_modules/tapable/lib/Tapable.js:37:47)
    at Tapable.MainTemplate.render (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/MainTemplate.js:111:20)
    at Tapable.createChunkAssets (/Users/alansouza/project-workspace/project/node_modules/gulp-webpack/node_modules/webpack/lib/Compilation.js:784:32)

After some investigation and checking out some suggestions in the webpack Gitter chat, I decided to remove the Dedupe Plugin and then everything works again, but my bundle size has increased significantly.

Any ideas on how to make the DedupePlugin work again? If I get any pointers I could try to solve the issue myself. Any help here is much appreciated.

Alan

@sokra sokra added the bug label May 19, 2015
@benoneal
Copy link

Suddenly started getting the same issue, only I'm using 1.4.15 and haven't updated anything:

node_modules/gulp-webpack/node_modules/webpack/lib/NormalModule.js:116
        if(!template) throw new Error("No template for dependency: " + dep.Class.nam
                            ^
Error: No template for dependency: TemplateArgumentDependency

I'm guessing some dependency updated with breaking changes without bumping the version enough, but that's just a stab in the dark because I'm having a lot of trouble tracking down the source of this sudden error.

@cheapsteak
Copy link
Contributor

Having a similar issue
Running webpack works, however, webpack-dev-server breaks with the "No template.." error, and removing the dedupe plugin fixes it

@gajus
Copy link
Member

gajus commented Aug 25, 2015

I am getting the same issue. Replicating it is kinda hard.

./foo/index.js

'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

// import ReactDOM from 'react-dom';

/bar/index.js

import Foo from './../foo/index.js';

Where foo and bar are separate modules.

Using this webpack.config.js:

var webpack = require('webpack'),
    path = require('path'),
    ExtractTextPlugin = require('extract-text-webpack-plugin'),
    devServer;

devServer = {
    contentBase: __dirname + '/endpoint',
    colors: true,
    quiet: false,
    noInfo: false,
    publicPath: '/',
    historyApiFallback: true,
    host: '127.0.0.1',
    port: 8000,
    hot: true
};

module.exports = {
    devtool: 'source-map',
    debug: false,
    devServer: devServer,
    context: __dirname + '/src',
    entry: {
        app: [
            './'
        ]
    },
    output: {
        path: __dirname + '/endpoint',
        filename: '[name].js',
        publicPath: devServer.publicPath
    },
    plugins: [
        new ExtractTextPlugin('app.css', {
            allChunks: true
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.OldWatchingPlugin(),
        // new webpack.NewWatchingPlugin(),
        // https://github.com/webpack/docs/wiki/optimization#deduplication
        new webpack.optimize.DedupePlugin(),
        new webpack.NoErrorsPlugin()
    ],
    module: {
        loaders: [
            {
                test: /\.js$/,
                include: path.resolve(__dirname, './src'),
                loader: 'babel'
            }
        ]
    },
    resolve: {
        extensions: [
            '',
            '.js'
        ]
    }
};

babel-loader is required.

@gajus
Copy link
Member

gajus commented Aug 25, 2015

Removing new webpack.optimize.DedupePlugin() makes it work.

@curiouslychase
Copy link

Has anyone figured out why this is causing this issue? I'm getting the same issue but deduping would be awesome rather than just getting rid of the plugin.

@gajus
Copy link
Member

gajus commented Sep 11, 2015

Since this is happening only when using webpack-dev-server, a simple solution would be to include the plugin only when running webpack command.

@miaojing
Copy link

I'm getting the same issue, I use it in webpack-dev-middleware.

@caccialdo
Copy link

Getting the same error without using webpack-dev-server here. We deactivated the plugin but it would be nice to be able to use it.

@caccialdo
Copy link

rm -rf node_modules && npm i solved the issue. Please ignore my previous message.

@nnnnathann
Copy link

+1

1 similar comment
@matthewmueller
Copy link

+1

@le0pard
Copy link

le0pard commented Nov 14, 2015

get the same issue today. npm shrinkwrap not safe from this.

@kyhwsk
Copy link

kyhwsk commented Nov 26, 2015

+1

@coopy
Copy link

coopy commented Dec 29, 2015

I was having the same issue using Webpack 1.11.0. Upgrading to 1.12.9 seems to have fixed the problem. You folks should try again with a newer version and see if this issue can be closed.

coopy pushed a commit to FormidableLabs/builder-victory-component that referenced this issue Dec 29, 2015
- Webpack: Export React as external, not Victory
- Upgrade Webpack to 1.12.9 for a fix to webpack/webpack#1082
@tribou
Copy link
Contributor

tribou commented Feb 24, 2016

I just hit this issue after adding twilio@^2 to my project which, in turn, required adding json-loader. Commenting out the Webpack.optimize.DedupePlugin works as a temporary fix. Just updated to webpack@1.12.14 as well but still no luck.

Did anyone ever find the root cause to this issue?

@princed
Copy link

princed commented Feb 24, 2016

@tribou #959 (comment)

@tribou
Copy link
Contributor

tribou commented Feb 27, 2016

Thanks!

For anyone encountering this in the future, the comment referenced above says:

Error: No template for dependency: TemplateArgumentDependency happens when you have multiple webpack copies installed and used the DedupePlugin from a different copy.

I was using a serverless-webpack-plugin which had it's own webpack dependency it was using to bundle files. However, I had manually installed and required webpack in my project's webpack config as well (like you normally would with webpack). Consequently, when I removed my explicitly installed version of webpack with npm rm --save-dev webpack, the plugin was able to require it's own scoped webpack dependency instead which worked.

I'll alert the serverless-webpack-plugin repo to this issue to figure out how to make it easier to use in the future.

@mouhsinelonly
Copy link

did anyone fix this issue , everything works fine on my locale machine but when i try to compile on the server i receive this error
i've deleted node_modules multiple times and did npm install,but with no luck

@tribou
Copy link
Contributor

tribou commented May 11, 2016

Do you have any dependencies that are requiring webpack? Also, did you install webpack globally on your local machine?

@BerndWessels
Copy link

BerndWessels commented May 12, 2016

@tribou I'm seeing this too

ERROR in chunk app [entry]
[name].bundle.js
No template for dependency: TemplateArgumentDependency

But unfortunately there are no other useful information and I removed the Dedupe Plugin already.

Any idea what can I do to fix it?

Everything is locally installed.

@tribou
Copy link
Contributor

tribou commented May 12, 2016

The issue I encountered above was that a dependency I was using didn't have webpack correctly listed as a peerDependency. Maybe verify that any webpack-related plugins or dependencies in your repo have webpack listed as a peer dep.

@BerndWessels
Copy link

@tribou Thanks, I will look at that too.

But I guess my problem is a bit weirder - since exactly the same project copied to another machine (including node_modules) works fine on one machine but has this error on the other machine.

@arlair
Copy link

arlair commented Jun 21, 2016

In case this helps anyone, I think my issue was related to using npm link. See here: http://stackoverflow.com/questions/37915849/webpack-chunkrendererror-no-template-for-dependency-templateargumentdependenc/

coopy pushed a commit to FormidableLabs/builder-docs-archetype that referenced this issue Sep 9, 2016
This matches the webapck version in formidable-playbook and
works around webpack/webpack#1082
toruta39 added a commit to toruta39/ReactNativeTodoMVC that referenced this issue Sep 19, 2016
@bebraw
Copy link
Contributor

bebraw commented Dec 24, 2016

I'm closing this as there's no DedupePlugin in webpack 2 anymore.

@bebraw bebraw closed this as completed Dec 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.