Skip to content

Commit

Permalink
Merge pull request #1 from ofabel/bugfix/issue_30
Browse files Browse the repository at this point in the history
  • Loading branch information
visurel authored Mar 19, 2023
2 parents f5fffa8 + 038ca9e commit 26dc038
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {getOptions} from 'loader-utils';
import {loader} from 'webpack';
import { getOptions } from 'loader-utils';
import { resolve } from 'path';
import { loader } from 'webpack';
import {
TwingEnvironment,
TwingLoaderArray,
TwingLoaderChain,
TwingNodeModule,
TwingSource, TwingTokenStream
} from 'twing';
import {Visitor} from "./visitor";
import { Visitor } from "./visitor";

const sha256 = require('crypto-js/sha256');
const hex = require('crypto-js/enc-hex');
Expand Down Expand Up @@ -56,7 +57,7 @@ export default function (this: loader.LoaderContext, source: string) {
let environmentModulePath: string = options.environmentModulePath;
let renderContext: any = options.renderContext;

this.addDependency(slash(environmentModulePath));
this.addDependency(resolve(slash(environmentModulePath)));

// require takes module name separated with forward slashes
let environment: TwingEnvironment = require(slash(environmentModulePath));
Expand Down Expand Up @@ -114,7 +115,8 @@ module.exports = (context = {}) => {
]));

environment.on('template', async (name: string, from: TwingSource) => {
this.addDependency(await environment.getLoader().resolve(name, from));
let sourceContext = await environment.getLoader().getSourceContext(name, from);
this.addDependency(resolve(sourceContext.getResolvedName()));
});

environment.render(resourcePath, renderContext).then((result) => {
Expand Down

0 comments on commit 26dc038

Please sign in to comment.