Skip to content
Permalink
Browse files

added: experimental sourcemap support

  • Loading branch information...
GianlucaGuarini committed Dec 17, 2017
1 parent 4ed7556 commit 29360f3761b15cb4dd206e8ecde08a08973db7b4
Showing with 20 additions and 40 deletions.
  1. +1 −0 .eslintignore
  2. +2 −28 .eslintrc.json
  3. +10 −6 index.js
  4. +5 −4 package.json
  5. +1 −1 test/expect/bundle-hot.js
  6. +1 −1 test/expect/bundle-normal.js
@@ -0,0 +1 @@
test/bundle.js
@@ -1,29 +1,3 @@
{
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"eqeqeq": ["error", "smart"],
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"no-cond-assign": "off",
"no-console": "off",
"no-unexpected-multiline": "error",
"quotes": ["error", "single", "avoid-escape"],
"semi": ["error", "never"]
},
"globals": {
"expect": true,
"body": true,
"chai": true,
"sinon": true,
"riot": true
}
}
"extends": "eslint-config-riot"
}
@@ -1,6 +1,5 @@
const riot = require('riot')
const loaderUtils = require('loader-utils')

const TAGS_NAMES_REGEX = /riot.tag2\(['|"](.+?)['|"],/g

/**
@@ -20,10 +19,15 @@ function hotReload(tags) {


module.exports = function(source) {
const query = loaderUtils.parseQuery(this.query)
const code = riot.compile(source, query, this.resourcePath)
const query = typeof this.query === 'string' ? loaderUtils.parseQuery(this.query) : this.query
const {code, map} = riot.compile(
source,
Object.assign(query, { sourcemap: true }),
this.resourcePath
)

const tags = []
var hotReloadCode = ''
let hotReloadCode = ''

code.replace(TAGS_NAMES_REGEX, function(_, match) {
tags.push(match)
@@ -32,9 +36,9 @@ module.exports = function(source) {
if (this.cacheable) this.cacheable()
if (query.hot) hotReloadCode = hotReload(tags)

return `
this.callback(null, `
var riot = require('riot')
${ code }
${ hotReloadCode }
`
`, map.toJSON())
}
@@ -28,11 +28,12 @@
},
"homepage": "https://github.com/riot/tag-loader#readme",
"dependencies": {
"loader-utils": "^0.2.16"
"loader-utils": "^1.1.0"
},
"devDependencies": {
"eslint": "^3.13.1",
"mocha": "^3.2.0",
"webpack": "^2.2.0"
"eslint": "^4.13.1",
"eslint-config-riot": "^1.0.0",
"mocha": "^4.0.1",
"webpack": "^3.10.0"
}
}

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

0 comments on commit 29360f3

Please sign in to comment.
You can’t perform that action at this time.