Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use relative path to resolve module #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion dist/createModuleAst/index.js
@@ -1,5 +1,13 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var path = __importStar(require("path"));
var importClause_1 = require("../astFactories/importClause");
var importDeclaration_1 = require("../astFactories/importDeclaration");
var declareModule_1 = require("../astFactories/declareModule");
Expand All @@ -10,8 +18,9 @@ var createInterfaceForRoot_1 = require("./createInterfaceForRoot");
var createInterfaceForLocalContext_1 = require("./createInterfaceForLocalContext");
//_______________________________________________________
//
var makeRelativePath = function (info) { return path.relative(info.distDir, info.filePath); };
exports.createModuleAst = function (sourceFile, fileInfo, constants) { return [
importClause_1.importClause(constants.MODULE, fileInfo.fileImportPath),
importClause_1.importClause(constants.MODULE, makeRelativePath(fileInfo)),
importDeclaration_1.importDeclaration(constants.VUEX),
declareModule_1.declareModule(constants.VUEX, [
createInterfaceForModules_1.createInterfaceForModules(fileInfo, constants),
Expand Down
5 changes: 4 additions & 1 deletion src/createModuleAst/index.ts
@@ -1,4 +1,5 @@
import * as ts from 'typescript'
import * as path from 'path'
import { FileInfo, Constants } from '../types'
import { importClause } from '../astFactories/importClause'
import { importDeclaration } from '../astFactories/importDeclaration'
Expand All @@ -10,12 +11,14 @@ import { createInterfaceForRoot } from './createInterfaceForRoot'
import { createInterfaceForLocalContext } from './createInterfaceForLocalContext'
//_______________________________________________________
//
const makeRelativePath = (info: FileInfo) => path.relative(info.distDir, info.fileImportPath)

export const createModuleAst = (
sourceFile: ts.SourceFile,
fileInfo: FileInfo,
constants: Constants
) => [
importClause(constants.MODULE, fileInfo.fileImportPath),
importClause(constants.MODULE, makeRelativePath(fileInfo)),
importDeclaration(constants.VUEX),
declareModule(constants.VUEX, [
createInterfaceForModules(fileInfo, constants),
Expand Down