mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Honor /** use babel */ in addition to 'use babel'
This commit is contained in:
@@ -33,6 +33,12 @@ describe "Babel transpiler support", ->
|
||||
observedDigest = babel.createBabelVersionAndOptionsDigest(version, defaultOptions)
|
||||
expect(observedDigest).toEqual expectedDigest
|
||||
|
||||
describe 'when a .js file starts with /** use babel */;', ->
|
||||
it "transpiles it using babel", ->
|
||||
transpiled = require('./fixtures/babel/babel-comment.js')
|
||||
expect(transpiled(3)).toBe 4
|
||||
expect(grim.getDeprecationsLength()).toBe 0
|
||||
|
||||
describe "when a .js file starts with 'use babel';", ->
|
||||
it "transpiles it using babel", ->
|
||||
transpiled = require('./fixtures/babel/babel-single-quotes.js')
|
||||
|
||||
3
spec/fixtures/babel/babel-comment.js
vendored
Normal file
3
spec/fixtures/babel/babel-comment.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/** use babel */
|
||||
|
||||
module.exports = v => v + 1
|
||||
@@ -142,7 +142,7 @@ transpile = (sourceCode, filePath, cachePath) ->
|
||||
# either generated on the fly or pulled from cache.
|
||||
loadFile = (module, filePath) ->
|
||||
sourceCode = fs.readFileSync(filePath, 'utf8')
|
||||
if sourceCode.startsWith('"use babel"') or sourceCode.startsWith("'use babel'")
|
||||
if sourceCode.startsWith('"use babel"') or sourceCode.startsWith("'use babel'") or sourceCode.startsWith('/** use babel */')
|
||||
# Continue.
|
||||
else if sourceCode.startsWith('"use 6to5"') or sourceCode.startsWith("'use 6to5'")
|
||||
# Create a manual deprecation since the stack is too deep to use Grim
|
||||
|
||||
Reference in New Issue
Block a user