mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
feat: sourceMap improvements
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@nativescript/webpack",
|
"name": "@nativescript/webpack",
|
||||||
"version": "5.0.0-dev",
|
"version": "5.0.0-beta.5",
|
||||||
"private": true,
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
@ -17,23 +17,24 @@
|
|||||||
"prepack": "npm test && npm run build && npm run copy-stubs && chmod +x dist/bin/index.js"
|
"prepack": "npm test && npm run build && npm run copy-stubs && chmod +x dist/bin/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "7.13.14",
|
"@babel/core": "7.13.15",
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
|
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
|
||||||
|
"acorn": "^8.1.1",
|
||||||
"acorn-stage3": "^4.0.0",
|
"acorn-stage3": "^4.0.0",
|
||||||
"babel-loader": "8.2.2",
|
"babel-loader": "8.2.2",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
"cli-highlight": "2.1.11",
|
"cli-highlight": "2.1.11",
|
||||||
"commander": "7.2.0",
|
"commander": "7.2.0",
|
||||||
"copy-webpack-plugin": "8.1.0",
|
"copy-webpack-plugin": "8.1.1",
|
||||||
"css": "3.0.0",
|
"css": "3.0.0",
|
||||||
"css-loader": "5.2.0",
|
"css-loader": "5.2.1",
|
||||||
"dotenv-webpack": "7.0.2",
|
"dotenv-webpack": "7.0.2",
|
||||||
"fork-ts-checker-webpack-plugin": "6.2.0",
|
"fork-ts-checker-webpack-plugin": "6.2.1",
|
||||||
"loader-utils": "2.0.0",
|
"loader-utils": "2.0.0",
|
||||||
"lodash.get": "4.4.2",
|
"lodash.get": "4.4.2",
|
||||||
"micromatch": "4.0.2",
|
"micromatch": "4.0.4",
|
||||||
"postcss": "8.2.8",
|
"postcss": "8.2.10",
|
||||||
"postcss-import": "14.0.0",
|
"postcss-import": "14.0.1",
|
||||||
"postcss-loader": "5.2.0",
|
"postcss-loader": "5.2.0",
|
||||||
"raw-loader": "4.0.2",
|
"raw-loader": "4.0.2",
|
||||||
"react-refresh": "0.10.0",
|
"react-refresh": "0.10.0",
|
||||||
@ -42,10 +43,10 @@
|
|||||||
"sax": "1.2.4",
|
"sax": "1.2.4",
|
||||||
"source-map": "0.7.3",
|
"source-map": "0.7.3",
|
||||||
"terser-webpack-plugin": "5.1.1",
|
"terser-webpack-plugin": "5.1.1",
|
||||||
"ts-dedent": "2.1.0",
|
"ts-dedent": "2.1.1",
|
||||||
"ts-loader": "8.1.0",
|
"ts-loader": "8.1.0",
|
||||||
"vue-loader": "15.9.6",
|
"vue-loader": "15.9.6",
|
||||||
"webpack": "5.28.0",
|
"webpack": "5.31.2",
|
||||||
"webpack-bundle-analyzer": "4.4.0",
|
"webpack-bundle-analyzer": "4.4.0",
|
||||||
"webpack-chain": "6.5.1",
|
"webpack-chain": "6.5.1",
|
||||||
"webpack-cli": "4.6.0",
|
"webpack-cli": "4.6.0",
|
||||||
@ -53,19 +54,19 @@
|
|||||||
"webpack-virtual-modules": "0.4.2"
|
"webpack-virtual-modules": "0.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/lodash.get": "4.4.6",
|
|
||||||
"@types/sax": "1.2.1",
|
|
||||||
"@types/css": "0.0.31",
|
"@types/css": "0.0.31",
|
||||||
"@types/jest": "26.0.22",
|
"@types/jest": "26.0.22",
|
||||||
"@types/loader-utils": "2.0.2",
|
"@types/loader-utils": "2.0.2",
|
||||||
|
"@types/lodash.get": "4.4.6",
|
||||||
"@types/micromatch": "4.0.1",
|
"@types/micromatch": "4.0.1",
|
||||||
|
"@types/sax": "1.2.1",
|
||||||
"@types/terser-webpack-plugin": "5.0.3",
|
"@types/terser-webpack-plugin": "5.0.3",
|
||||||
"@types/webpack-virtual-modules": "0.1.1",
|
"@types/webpack-virtual-modules": "0.1.1",
|
||||||
"jest": "26.6.3",
|
"jest": "26.6.3",
|
||||||
"jest-matcher-utils": "26.6.2",
|
"jest-matcher-utils": "26.6.2",
|
||||||
"nativescript-vue-template-compiler": "2.8.4",
|
"nativescript-vue-template-compiler": "2.9.0",
|
||||||
"ts-jest": "26.5.4",
|
"ts-jest": "26.5.4",
|
||||||
"typescript": "4.2.3"
|
"typescript": "4.2.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"nativescript-vue-template-compiler": "^2.8.1"
|
"nativescript-vue-template-compiler": "^2.8.1"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {
|
import webpack, {
|
||||||
ContextExclusionPlugin,
|
ContextExclusionPlugin,
|
||||||
DefinePlugin,
|
DefinePlugin,
|
||||||
HotModuleReplacementPlugin,
|
HotModuleReplacementPlugin,
|
||||||
@ -44,8 +44,30 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
// resolved at runtime
|
// resolved at runtime
|
||||||
config.externals(['package.json', '~/package.json']);
|
config.externals(['package.json', '~/package.json']);
|
||||||
|
|
||||||
// todo: devtool
|
const getSourceMapType = (map: string | boolean): Config.DevTool => {
|
||||||
config.devtool('inline-source-map');
|
const defaultSourceMap = 'inline-source-map';
|
||||||
|
|
||||||
|
if (typeof map === 'undefined') {
|
||||||
|
// source-maps disabled in production by default
|
||||||
|
// enabled with --env.sourceMap=<type>
|
||||||
|
if (mode === 'production') {
|
||||||
|
// todo: we may set up SourceMapDevToolPlugin to generate external maps in production
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultSourceMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// when --env.sourceMap=true is passed, use default
|
||||||
|
if (typeof map === 'boolean' && map) {
|
||||||
|
return defaultSourceMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pass any type of sourceMap with --env.sourceMap=<type>
|
||||||
|
return map as Config.DevTool;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.devtool(getSourceMapType(env.sourceMap));
|
||||||
|
|
||||||
// todo: figure out easiest way to make "node" target work in ns
|
// todo: figure out easiest way to make "node" target work in ns
|
||||||
// rather than the custom ns target implementation that's hard to maintain
|
// rather than the custom ns target implementation that's hard to maintain
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
// This must be at the top BEFORE webpack is loaded so that we can extend
|
// This must be at the top BEFORE webpack is loaded so that we can extend
|
||||||
// and replace the parser before webpack uses it
|
// and replace the parser before webpack uses it
|
||||||
// Based on the issue: https://github.com/webpack/webpack/issues/10216
|
// Based on the issue: https://github.com/webpack/webpack/issues/10216
|
||||||
const stage3 = require('acorn-stage3');
|
import stage3 from 'acorn-stage3';
|
||||||
|
|
||||||
|
// we use require to be able to override the exports
|
||||||
const acorn = require('acorn');
|
const acorn = require('acorn');
|
||||||
acorn.Parser = acorn.Parser.extend(stage3);
|
acorn.Parser = acorn.Parser.extend(stage3);
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ export interface IWebpackEnv {
|
|||||||
// for custom platforms
|
// for custom platforms
|
||||||
platform?: string;
|
platform?: string;
|
||||||
|
|
||||||
|
sourceMap?: string | boolean;
|
||||||
production?: boolean;
|
production?: boolean;
|
||||||
report?: boolean;
|
report?: boolean;
|
||||||
hmr?: boolean;
|
hmr?: boolean;
|
||||||
|
Reference in New Issue
Block a user