Skip to content

Commit

Permalink
updated: bundled files
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Jun 10, 2019
1 parent c7f5411 commit fbf7ab1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions dist/riot-webpack-loader.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var loaderUtils = require('loader-utils');

/**
* Generate the hmr code depending on the tag generated by the compiler
* @param {string} path - path to the component file
* @param {string} path - stringified, quote-enclosed path to the component file
* @returns {string} the code needed to handle the riot hot reload
*/
function hotReload(path) {
Expand All @@ -14,7 +14,7 @@ function hotReload(path) {
const hotReload = require('@riotjs/hot-reload').default
module.hot.accept()
if (module.hot.data) {
const component = require('${path}').default;
const component = require(${path}).default;
hotReload(component)
}
}
Expand All @@ -41,7 +41,9 @@ function index(source) {
);

// generate the output code
const output = `${code}${opts.hot ? hotReload(this.resourcePath) : ''}`;
// convert webpack's absolute path to a script-friendly string for hotReload
const escapedPath = loaderUtils.stringifyRequest(this, this.resourcePath);
const output = `${code}${opts.hot ? hotReload(escapedPath) : ''}`;

// cache this module
if (this.cacheable) this.cacheable();
Expand Down
10 changes: 6 additions & 4 deletions dist/riot-webpack-loader.esm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { compile } from '@riotjs/compiler';
import { getOptions } from 'loader-utils';
import { getOptions, stringifyRequest } from 'loader-utils';

/**
* Generate the hmr code depending on the tag generated by the compiler
* @param {string} path - path to the component file
* @param {string} path - stringified, quote-enclosed path to the component file
* @returns {string} the code needed to handle the riot hot reload
*/
function hotReload(path) {
Expand All @@ -12,7 +12,7 @@ function hotReload(path) {
const hotReload = require('@riotjs/hot-reload').default
module.hot.accept()
if (module.hot.data) {
const component = require('${path}').default;
const component = require(${path}).default;
hotReload(component)
}
}
Expand All @@ -39,7 +39,9 @@ function index(source) {
);

// generate the output code
const output = `${code}${opts.hot ? hotReload(this.resourcePath) : ''}`;
// convert webpack's absolute path to a script-friendly string for hotReload
const escapedPath = stringifyRequest(this, this.resourcePath);
const output = `${code}${opts.hot ? hotReload(escapedPath) : ''}`;

// cache this module
if (this.cacheable) this.cacheable();
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {compile} from '@riotjs/compiler'
import {getOptions, stringifyRequest} from 'loader-utils'
import {compile} from '@riotjs/compiler'

/**
* Generate the hmr code depending on the tag generated by the compiler
Expand Down

0 comments on commit fbf7ab1

Please sign in to comment.