diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-27 19:33:54 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-27 19:34:16 +0100 |
commit | 0e6de2c31dbf8c21277481f112e99c52b913940f (patch) | |
tree | 91789032de3b8eec9d789acd1323f25fc5d08422 /node_modules/babel-generator/README.md | |
parent | ceda0da31ad542c598c68146ae0712ca03df3d71 (diff) |
node_modules
Diffstat (limited to 'node_modules/babel-generator/README.md')
-rw-r--r-- | node_modules/babel-generator/README.md | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/node_modules/babel-generator/README.md b/node_modules/babel-generator/README.md index a33719135..ff215b753 100644 --- a/node_modules/babel-generator/README.md +++ b/node_modules/babel-generator/README.md @@ -54,12 +54,7 @@ sourceFileName | string | | The filename for the sourc In most cases, Babel does a 1:1 transformation of input-file to output-file. However, you may be dealing with AST constructed from multiple sources - JS files, templates, etc. If this is the case, and you want the sourcemaps to reflect the correct sources, you'll need -to make some changes to your code. - -First, each node with a `loc` property (which indicates that node's original placement in the -source document) must also include a `loc.filename` property, set to the source filename. - -Second, you should pass an object to `generate` as the `code` parameter. Keys +to pass an object to `generate` as the `code` parameter. Keys should be the source filenames, and values should be the source content. Here's an example of what that might look like: @@ -70,14 +65,14 @@ import generate from 'babel-generator'; const a = 'var a = 1;'; const b = 'var b = 2;'; -const astA = parse(a, { filename: 'a.js' }); -const astB = parse(b, { filename: 'b.js' }); +const astA = parse(a, { sourceFilename: 'a.js' }); +const astB = parse(b, { sourceFilename: 'b.js' }); const ast = { type: 'Program', - body: [].concat(astA.body, ast2.body) + body: [].concat(astA.program.body, astB.program.body) }; -const { code, map } = generate(ast, { /* options */ }, { +const { code, map } = generate(ast, { sourceMaps: true }, { 'a.js': a, 'b.js': b }); |