Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 384bee2

Browse files
author
Dimitar Tachev
authored
fix: typescript source maps are containing javascript code (#857)
* fix: avoid losing the source map in some loader * fix: generate TypeScript source maps
1 parent 196d977 commit 384bee2

9 files changed

+33
-28
lines changed

‎android-app-components-loader.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { convertSlashesInPath } = require("./projectHelpers");
22

3-
module.exports = function (source) {
3+
module.exports = function (source,map) {
44
this.cacheable();
55
const { modules } = this.query;
66
const imports = modules.map(convertSlashesInPath)
@@ -14,5 +14,5 @@ module.exports = function (source) {
1414
${source}
1515
`;
1616

17-
this.callback(null, augmentedSource);
17+
this.callback(null, augmentedSource,map);
1818
};

‎apply-css-loader.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(content) {
1+
module.exports = function(content,map) {
22
if (this.request.match(/\/app\.(css|scss|less|sass)$/)) {
33
return content;
44
}
@@ -14,5 +14,5 @@ module.exports = function(content) {
1414
});
1515
`;
1616

17-
return content;
17+
this.callback(null, content,map);
1818
}

‎bundle-config-loader.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const unitTestingConfigLoader = require("./unit-testing-config-loader");
22

3-
module.exports = function (source) {
3+
module.exports = function (source,map) {
44
this.cacheable();
55
const { angular = false, loadCss = true, unitTesting, projectRoot, appFullPath, registerModules = /(root|page)\.(xml|css|js|ts|scss)$/ } = this.query;
66

@@ -66,5 +66,5 @@ module.exports = function (source) {
6666
`;
6767
}
6868

69-
this.callback(null, source);
69+
this.callback(null, source,map);
7070
};

‎css2json-loader.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
const parse = require("tns-core-modules/css").parse;
22
const nl = "\n";
33

4-
module.exports = function(content) {
4+
module.exports = function(content,map) {
55
const ast = parse(content);
66
const dependencies = getImportsFrom(ast)
77
.map(mapURI)
8-
.reduce((dependencies, {uri, requireURI}) =>
8+
.reduce((dependencies, {uri, requireURI}) =>
99
dependencies + `global.registerModule(${uri}, () => require(${requireURI}));${nl}`, "");
1010

1111
const str = JSON.stringify(ast, (k, v) => k === "position" ? undefined : v);
12-
return `${dependencies}module.exports = ${str};`;
12+
this.callback(null, `${dependencies}module.exports = ${str};`,map);
1313
}
1414

1515
function getImportsFrom(ast) {

‎markup-hot-loader.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const { reload } = require("./hot-loader-helper");
22
const { convertToUnixPath } = require("./lib/utils");
33

4-
module.exports = function (source) {
4+
module.exports = function (source,map) {
55
const typeMarkup = "markup";
66
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
77
const modulePath = convertToUnixPath(moduleRelativePath);
8-
return `${source};${reload({ type: typeMarkup, path: modulePath })}`;
8+
9+
this.callback(null, `${source};${reload({ type: typeMarkup, path: modulePath })}`, map);
910
};

‎script-hot-loader.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const { reload } = require("./hot-loader-helper");
22
const { convertToUnixPath } = require("./lib/utils");
33

4-
module.exports = function (source) {
4+
module.exports = function (source,map) {
55
const typeScript = "script";
66
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
77
const modulePath = convertToUnixPath(moduleRelativePath);
8-
return `${source};${reload({ type: typeScript, path: modulePath })}`;
8+
this.callback(null, `${source};${reload({ type: typeScript, path: modulePath })}`,map);
99
};

‎style-hot-loader.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const { reload } = require("./hot-loader-helper");
22
const { convertToUnixPath } = require("./lib/utils");
33

4-
module.exports = function (source) {
4+
module.exports = function (source,map) {
55
const typeStyle = "style";
66
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
77
const modulePath = convertToUnixPath(moduleRelativePath);
8-
return `${source};${reload({ type: typeStyle, path: modulePath })}`;
8+
9+
this.callback(null, `${source};${reload({ type: typeStyle, path: modulePath })}`, map);
910
};

‎templates/webpack.typescript.js‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
88
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
99
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
1010
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
11-
const hashSalt = Date.now().toString();
11+
const hashSalt = Date.now().toString();
1212

1313
module.exports = env => {
1414
// Add your custom Activities, Services and other Android app components here.
@@ -115,7 +115,7 @@ module.exports = env => {
115115
test: (module, chunks) => {
116116
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
117117
return /[\\/]node_modules[\\/]/.test(moduleName) ||
118-
appComponents.some(comp => comp === moduleName);
118+
appComponents.some(comp => comp === moduleName);
119119

120120
},
121121
enforce: true,
@@ -179,7 +179,7 @@ module.exports = env => {
179179
use: "nativescript-dev-webpack/markup-hot-loader"
180180
},
181181

182-
{ test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"},
182+
{ test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"},
183183

184184
{
185185
test: /\.css$/,
@@ -201,6 +201,9 @@ module.exports = env => {
201201
options: {
202202
configFile: "tsconfig.tns.json",
203203
allowTsInNodeModules: true,
204+
compilerOptions: {
205+
sourceMap
206+
}
204207
},
205208
}
206209
},
@@ -213,7 +216,7 @@ module.exports = env => {
213216
"process": undefined,
214217
}),
215218
// Remove all files from the out dir.
216-
new CleanWebpackPlugin([`${dist}/**/*`]),
219+
new CleanWebpackPlugin([`${dist}/**/*`]),
217220
// Copy assets to out dir. Add your own globs as needed.
218221
new CopyWebpackPlugin([
219222
{ from: { glob: "fonts/**" } },
@@ -226,10 +229,10 @@ module.exports = env => {
226229
// configures the WebPack runtime to be generated inside the snapshot
227230
// module and no `runtime.js` module exist.
228231
(snapshot ? [] : ["./runtime"])
229-
.concat([
230-
"./vendor",
231-
"./bundle",
232-
])
232+
.concat([
233+
"./vendor",
234+
"./bundle",
235+
])
233236
),
234237
// For instructions on how to set up workers with webpack
235238
// check out https://github.com/nativescript/worker-loader

‎xml-namespace-loader.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { parse, relative, join, basename, extname } = require("path");
22
const { promisify } = require('util');
33
const { convertSlashesInPath } = require("./projectHelpers");
44

5-
module.exports = function (source) {
5+
module.exports = function (source,map) {
66
this.value = source;
77
const { ignore } = this.query;
88
const callback = this.async();
@@ -41,14 +41,14 @@ module.exports = function (source) {
4141
this.addDependency(xml);
4242
namespaces.push({ name: `${moduleName}.xml`, path: xml });
4343
})
44-
.catch((err) => {}),
44+
.catch((err) => {}),
4545

4646
resolvePromise(this.context, `${noExtFilename}.css`)
4747
.then((css) => {
4848
this.addDependency(css);
4949
namespaces.push({ name: `${moduleName}.css`, path: css });
5050
})
51-
.catch((err) => {})
51+
.catch((err) => {})
5252
]);
5353
};
5454

@@ -75,7 +75,7 @@ module.exports = function (source) {
7575
namespaces.push({ name: `${moduleName}.css`, path: css });
7676
this.addDependency(css);
7777
})
78-
.catch(() => {})
78+
.catch(() => {})
7979
]);
8080

8181
});
@@ -102,7 +102,7 @@ module.exports = function (source) {
102102

103103
const wrapped = `${moduleRegisters}\nmodule.exports = ${json}`;
104104

105-
callback(null, wrapped);
105+
callback(null, wrapped,map);
106106
}).catch((err) => {
107107
callback(err);
108108
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /