yahoo / serialize-javascript

Serialize JavaScript to a superset of JSON that includes regular expressions and functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use in the browser

marcelstoer opened this issue · comments

I thought it'd be easy to use serialize-javascript in the browser but I'm obviously doing something wrong.

I created an index.js which contains a single line

var serialize = require('serialize-javascript');

Then I installed browserify (sudo npm install browserify -g), installed serialize-javascript (npm install serialize-javascript) and ran browserify index.js > serialize-javascript.js.

After I load serialize-javascript.js in the browser there's no serialize() function available.

You will have to use browserify options to make that serialize a global function, or just do that manually in your index.js, no change is required is this package.

commented

You will have to use browserify options to make that serialize a global function, or just do that manually in your index.js, no change is required is this package.

Could you give an example?

Just remove module.exports =