feat: ported xml-namespace-loader

This commit is contained in:
Igor Randjelovic
2020-11-28 21:26:16 +01:00
parent 803958266d
commit 5b182c0d5f
7 changed files with 699 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ import {
getEntryPath,
getPlatform,
} from '../helpers/project';
import { hasDependency } from '../helpers/dependencies';
export default function (config: Config, env: IWebpackEnv): Config {
const entryPath = getEntryPath();
@@ -136,13 +137,17 @@ export default function (config: Config, env: IWebpackEnv): Config {
});
// Use Fork TS Checker to do type checking in a separate non-blocking process
config.plugin('ForkTsCheckerWebpackPlugin').use(ForkTsCheckerWebpackPlugin, [
{
typescript: {
memoryLimit: 4096,
},
},
]);
config.when(hasDependency('typescript'), (config) => {
config
.plugin('ForkTsCheckerWebpackPlugin')
.use(ForkTsCheckerWebpackPlugin, [
{
typescript: {
memoryLimit: 4096,
},
},
]);
});
// set up js
// todo: do we need babel-loader? It's useful to support it

View File

@@ -1,18 +1,37 @@
import VirtualModulesPlugin from 'webpack-virtual-modules';
import Config from 'webpack-chain';
import { getEntryPath } from '../helpers/project';
import { IWebpackEnv } from '../index';
import base from './base';
import dedent from 'ts-dedent';
// todo: add base configuration for core with javascript
export default function (config: Config, env: IWebpackEnv): Config {
base(config, env);
const virtualEntryPath = getEntryPath() + '.virtual.js';
config.entry('bundle').add(virtualEntryPath);
// Add a virtual entry module
config.plugin('VirtualModulesPlugin').use(VirtualModulesPlugin, [
{
[virtualEntryPath]: dedent`
require('@nativescript/core/bundle-entry-points')
const context = require.context("./", /* deep: */ true);
global.registerWebpackModules(context);
`,
},
]);
// set up xml
config.module
.rule('xml')
.test(/\.xml$/)
.use('xml-loader')
.loader('xml-loader');
.use('xml-namespace-loader')
.loader('xml-namespace-loader');
return config;
}