Giter VIP home page Giter VIP logo

lodash-template-webpack-loader's People

Contributors

duhaime avatar kmck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lodash-template-webpack-loader's Issues

Can't pipeline to babel-loader 8

Hi.
First of all, sorry about my terrible English. ( almost all Japanese is. )

We are trying to transpile emdebedded javascript code from lodash/template by babel 8.

// webpack.config.js (webpack 4)
module.exports = {
  devtool: 'eval-source-map'
  module: {
    rules: [
        test: /\.tpl$/,
        use: [
          'babel-loader',
          'lodash-template-webpack-loader'
        ]
      },

above setting cause bable-loader Error.

Error: .inputSourceMap must be a boolean, object, or undefined

because of babel-loader does not accept SourceMap as 'string' type.

// code inside babel (sorry no link. can't Find in GitHub)
function assertInputSourceMap(loc, value) {
  if (value !== undefined && typeof value !== "boolean" && (typeof value !== "object" || !value)) {
    throw new Error(`${msg(loc)} must be a boolean, object, or undefined`);
  }

  return value;
}

I tried patch to lodash-template-webpack-loader (local).

map = sourceMapGenerator.toString();

// index.js
    // Source map
    if (!map && (this.sourceMap || params.sourceMap || options.sourceMap)) {
        var sourceMapGenerator = new SourceMapGenerator({
            file: this.resourcePath,
        });
        sourceMapGenerator.setSourceContent(this.resourcePath, content);
        sourceMapGenerator.addMapping({
            source: this.resourcePath,
            original: {line: 1, column: 0},
            generated: {line: 1, column: 0},
        });
        // map = sourceMapGenerator.toString();  // -> OUT
        map = sourceMapGenerator.toJSON();  // <- IN        
    }

and works fine.

below works too, result is different however.

// webpack.config.js
    rules: [
        test: /\.tpl$/,
        use: [
          'babel-loader',
          'test-loader',
          'lodash-template-webpack-loader'
        ]
      },

// test-loader.js
module.exports = function(content, map, meta) {
  // this.callback(null, content, JSON.parse(map), meta); // -> cause parse Error
  this.callback(null, content, null, meta);
};

We hope that this module to be available switching sourceMap type to Json object.

Not found fallback-loader.js

development works great!
but webpack build consistently fails with fallback-loader.js can not found.

➜ npm i -D lodash-template-webpack-loader
➜ cd node_modules/lodash-template-webpack-loader/
➜ ll
total 48
-rw-r--r--  1 iwa  staff   1.1K  5  3  2016 LICENSE
-rw-r--r--  1 iwa  staff   7.2K  5  6  2016 README.md
-rw-r--r--  1 iwa  staff   6.2K  5  6  2016 index.js
drwxr-xr-x  3 iwa  staff   102B  9 29 01:18 lib
drwxr-xr-x  3 iwa  staff   102B  9 29 01:18 node_modules
-rw-r--r--  1 iwa  staff   2.3K  9 29 01:18 package.json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.