File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,6 +88,47 @@ Error: <PROJECT_ROOT>/src/__tests__/index.js: codegen: Must module.exports a str
8888
8989`;
9090
91+ exports[`5. includes code comments 1`] = `
92+
93+ codegen\`
94+ module.exports = \\\`
95+ // before
96+ var x = 'hi'
97+ /*
98+ * after
99+ */
100+
101+ // call foo
102+ console.log(foo())
103+
104+ /**
105+ * jsdoc
106+ * @return { string } cool I guess
107+ */
108+ function foo() {
109+ return ' foo'
110+ }
111+ \\\`
112+ \`
113+
114+ ↓ ↓ ↓ ↓ ↓ ↓
115+
116+ // before
117+ var x = 'hi'; /*
118+ * after
119+ */ // call foo
120+
121+ console.log(foo()); /**
122+ * jsdoc
123+ * @return { string } cool I guess
124+ */
125+
126+ function foo() {
127+ return ' foo' ;
128+ }
129+
130+ `;
131+
91132exports[`6. codegen 1`] = `
92133
93134// @codegen
Original file line number Diff line number Diff line change @@ -111,5 +111,27 @@ pluginTester({
111111 'handles multipe nodes' : `
112112 codegen.require('./fixtures/multiple-nodes')
113113 ` ,
114+ 'includes code comments' : `
115+ codegen\`
116+ module.exports = \\\`
117+ // before
118+ var x = 'hi'
119+ /*
120+ * after
121+ */
122+
123+ // call foo
124+ console.log(foo())
125+
126+ /**
127+ * jsdoc
128+ * @return {string} cool I guess
129+ */
130+ function foo() {
131+ return 'foo'
132+ }
133+ \\\`
134+ \`
135+ ` ,
114136 } ,
115137} )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ function stringToAST(string) {
2020 }
2121 return template ( string , {
2222 sourceType : 'module' ,
23+ preserveComments : true ,
2324 plugins : [
2425 // add more on request...
2526 'jsx' ,
You can’t perform that action at this time.
0 commit comments