pluma / literalify

UNMAINTAINED. A browserify transform for replacing require calls with arbitrary code.
MIT License
60 stars 0 forks source link

prombem with `.json` file parsing #3

Closed pierr closed 9 years ago

pierr commented 9 years ago

When I use literalify with browserify. I have an error when i require a .json file.

var version = require('./package.json'); //Usally works with browserify alone
console.log(version);

I get the following stack trace in my console:

SyntaxError: Unexpected token (2:19) (while literalify was processing d:\Sources
\github\focus\build.json) while parsing file: d:\Sources\github\focus\build.json

    at raise (d:\Sources\github\focus\node_modules\literalify\node_modules\brows
erify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:333:15)
    at unexpected (d:\Sources\github\focus\node_modules\literalify\node_modules\
browserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:1366
:5)
    at semicolon (d:\Sources\github\focus\node_modules\literalify\node_modules\b
rowserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:1353:
47)
    at parseExpressionStatement (d:\Sources\github\focus\node_modules\literalify
\node_modules\browserify-transform-tools\node_modules\falafel\node_modules\acorn
\acorn.js:1803:5)
    at parseStatement (d:\Sources\github\focus\node_modules\literalify\node_modu
les\browserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:
1589:19)
    at parseBlock (d:\Sources\github\focus\node_modules\literalify\node_modules\
browserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:1826
:18)
    at parseStatement (d:\Sources\github\focus\node_modules\literalify\node_modu
les\browserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:
1572:26)
    at parseTopLevel (d:\Sources\github\focus\node_modules\literalify\node_modul
es\browserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:1
526:18)
    at exports.parse (d:\Sources\github\focus\node_modules\literalify\node_modul
es\browserify-transform-tools\node_modules\falafel\node_modules\acorn\acorn.js:4
8:12)
    at module.exports (d:\Sources\github\focus\node_modules\literalify\node_modu
les\browserify-transform-tools\node_modules\falafel\index.js:31:15)

My browserify build is as follows:

var babelify = require("babelify"); //es6
  var browserify = require('browserify'); //build the source
  var source = require('vinyl-source-stream');
    var literalify = require('literalify');
    return browserify(({
        entries: ['./index.js'],
        extensions: ['.jsx'],
        standalone: "focus"
      }))
      .transform(
        {global:true},
        literalify.configure({
        react: 'window.React'
      }))
      .transform(babelify)
      .bundle()
      //Pass desired output filename to vinyl-source-stream
      .pipe(source("focus-"+require('./package.json').version+".js"))
      .pipe(gulp.dest('./dist/'));
pluma commented 9 years ago

Thanks for the report. I'll probably have to update the dependencies before digging any deeper. Browserify has changed a bit in the year since I last touched this module.

pluma commented 9 years ago

This has been fixed in 0.4.0. Thanks again for reporting this issue.