Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Fix issue #30 #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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