File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "env": {
3+ "es6": true,
4+ "jest": true,
5+ "node": true
6+ },
7+ "extends": "eslint:recommended"
8+ }
Original file line number Diff line number Diff line change 1- const babel = require ( '@babel/core' )
2- const plugin = require ( '../index.js' )
1+ const babel = require ( '@babel/core' ) ;
2+ const plugin = require ( '../index.js' ) ;
33
44const options = {
55 presets : [
6- [ " @babel/env" , {
7- " modules" : false
6+ [ ' @babel/env' , {
7+ modules : false
88 } ]
99 ] ,
1010 plugins : [
1111 plugin
1212 ]
13- }
13+ } ;
1414
1515it ( 'Module imports are stripped' , ( ) => {
16- var example = `
17- import fs from 'fs'
18- import path from 'path'
19- `
20-
21- const { code} = babel . transform ( example , options )
22- expect ( code . length ) . toBe ( 0 )
23- } )
16+ const example = `
17+ import path from 'path';
18+ ` ;
19+
20+ const { code } = babel . transformSync ( example , options ) ;
21+ expect ( code . length ) . toBe ( 0 ) ;
22+ } ) ;
23+
24+ it ( 'Module exports are stripped' , ( ) => {
25+ const example = `
26+ export default 42;
27+ ` ;
28+
29+ const { code } = babel . transformSync ( example , options ) ;
30+ expect ( code . length ) . toBe ( 0 ) ;
31+ } ) ;
32+
33+ it ( 'Other code is retained' , ( ) => {
34+ const example = `
35+ import path from 'path';
36+
37+ console.log(path.sep);
38+
39+ export default 42;
40+ ` ;
41+
42+ const { code } = babel . transformSync ( example , options ) ;
43+ expect ( code ) . toBe ( 'console.log(path.sep);' ) ;
44+ } ) ;
You can’t perform that action at this time.
0 commit comments