Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1127 from NativeScript/vmutafov/kotlinjs
Browse files Browse the repository at this point in the history
feat: Add initial support for KotlinJS
  • Loading branch information
rosen-vladimirov authored Feb 21, 2020
2 parents 661c3c4 + a04c0f8 commit 39cb24d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bundle-config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getOptions } from "loader-utils";
import * as escapeRegExp from "escape-string-regexp";

// Matches all source, markup and style files that are not in App_Resources and in tests folder
const defaultMatch = "(?<!\\bApp_Resources\\b.*)(?<!\\.\\/\\btests\\b\\/.*?)\\.(xml|css|js|(?<!\\.d\\.)ts|(?<!\\b_[\\w-]*\\.)scss)$";
const defaultMatch = "(?<!\\bApp_Resources\\b.*)(?<!\\.\\/\\btests\\b\\/.*?)\\.(xml|css|js|kt|(?<!\\.d\\.)ts|(?<!\\b_[\\w-]*\\.)scss)$";

const loader: loader.Loader = function (source, map) {
let {
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ exports.getEntryModule = function (appDirectory, platform) {
const entry = getPackageJsonEntry(appDirectory);

const tsEntryPath = path.resolve(appDirectory, `${entry}.ts`);
const ktEntryPath = path.resolve(appDirectory, `${entry}.kt`);
const jsEntryPath = path.resolve(appDirectory, `${entry}.js`);
let entryExists = existsSync(tsEntryPath) || existsSync(jsEntryPath);
let entryExists = existsSync(tsEntryPath) || existsSync(ktEntryPath) || existsSync(jsEntryPath);
if (!entryExists && platform) {
const platformTsEntryPath = path.resolve(appDirectory, `${entry}.${platform}.ts`);
const platformKtEntryPath = path.resolve(appDirectory, `${entry}.${platform}.kt`);
const platformJsEntryPath = path.resolve(appDirectory, `${entry}.${platform}.js`);
entryExists = existsSync(platformTsEntryPath) || existsSync(platformJsEntryPath);
entryExists = existsSync(platformTsEntryPath) || existsSync(platformKtEntryPath) || existsSync(platformJsEntryPath);
}

if (!entryExists) {
Expand Down Expand Up @@ -208,7 +210,7 @@ function getPackageJsonEntry(appDirectory) {
throw new Error(`${appDirectory}/package.json must contain a 'main' attribute!`);
}

return entry.replace(/\.js$/i, "");
return entry.replace(/\.js$/i, "").replace(/\.kt$/i, "");
}

function verifyEntryModuleDirectory(appDirectory) {
Expand Down

0 comments on commit 39cb24d

Please sign in to comment.