Skip to content

Commit 5799cb4

Browse files
authored
Merge branch 'master' into master
2 parents 9cf33e4 + 7deb117 commit 5799cb4

19 files changed

+103
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<a name="0.8.0"></a>
2+
# [0.8.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.7.3...0.8.0) (2017-09-08)
3+
4+
### Features
5+
6+
* add support for web workers to default template ([#269](https://github.com/NativeScript/nativescript-dev-webpack/issues/269)) ([494ccbb](https://github.com/NativeScript/nativescript-dev-webpack/commit/494ccbb))
7+
8+
19
<a name="0.7.3"></a>
210
## [0.7.3](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.7.2...0.7.3) (2017-07-12)
311

bin/generate-android-snapshot

100644100755
File mode changed.

bin/install-ns-webpack

100644100755
File mode changed.

bin/ns-bundle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const { existsSync } = require("fs");
66

77
const semver = require("semver");
88

9-
const { getPackageJson } = require("../projectHelpers");
9+
const { getPackageJson, getProjectDir } = require("../projectHelpers");
1010

11-
const PROJECT_DIR = pathResolve(__dirname, "../../../");
11+
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
1212
const packageJson = getPackageJson(PROJECT_DIR);
1313

1414
if (!process.env.npm_config_argv) {
@@ -152,7 +152,9 @@ function webpack(platform, env) {
152152
console.log(`Running webpack for ${platform}...`);
153153

154154
const args = [
155-
`webpack`,
155+
`node`,
156+
`--preserve-symlinks`,
157+
`./node_modules/.bin/webpack`,
156158
`--config=webpack.config.js`,
157159
`--progress`,
158160
`--env.${platform}`,

bin/ns-verify-bundle

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
const path = require("path");
44
const fs = require("fs");
55

6-
const PROJECT_DIR = path.resolve(__dirname, "../../../");
6+
const { getProjectDir } = require("../projectHelpers");
7+
8+
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
79
const APP_ID = require(path.resolve(PROJECT_DIR, "./package.json")).nativescript.id;
810
const APP_NAME = APP_ID.substring(APP_ID.lastIndexOf(".") + 1);
911
const PROJECT_PATHS = {

bin/remove-ns-webpack

100644100755
File mode changed.

bin/update-ns-webpack

100644100755
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env node
22
const { resolve } = require("path");
33

4-
const { getPackageJson, writePackageJson } = require("../projectHelpers");
4+
const { getPackageJson, getProjectDir, writePackageJson } = require("../projectHelpers");
55
const { forceUpdateProjectDeps } = require("../dependencyManager");
66
const { editExistingProjectFiles } = require("../projectFilesManager");
77

8-
const PROJECT_DIR = resolve(__dirname, "../../../");
8+
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
9+
const packageJson = getPackageJson(PROJECT_DIR);
910

1011
console.info("Updating dev dependencies...");
11-
const packageJson = getPackageJson(PROJECT_DIR);
12+
1213
const { deps } = forceUpdateProjectDeps(packageJson);
1314
packageJson.devDependencies = deps;
1415
writePackageJson(packageJson, PROJECT_DIR);

dependencyManager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function getRequiredDeps(packageJson) {
6464
"copy-webpack-plugin": "~4.0.1",
6565
"raw-loader": "~0.5.1",
6666
"nativescript-css-loader": "~0.26.0",
67+
"nativescript-worker-loader": "~0.8.1",
6768
"resolve-url-loader": "~2.1.0",
6869
"extract-text-webpack-plugin": "~3.0.0",
6970
};

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const path = require("path");
22
const { existsSync } = require("fs");
33

4-
const { getPackageJson, isAngular } = require("./projectHelpers");
4+
const { getPackageJson, getProjectDir, isAngular } = require("./projectHelpers");
55

6-
const PROJECT_DIR = path.dirname(path.dirname(__dirname));
6+
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
77
const APP_DIR = path.join(PROJECT_DIR, "app");
88

99
Object.assign(exports, require('./plugins'));

installer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const projectFilesManager = require("./projectFilesManager");
66
const npmScriptsManager = require("./npmScriptsManager");
77
const dependencyManager = require("./dependencyManager");
88

9-
const PROJECT_DIR = path.dirname(path.dirname(__dirname));
9+
const PROJECT_DIR = helpers.getProjectDir({ nestingLvl: 2 });
1010
const APP_DIR = path.resolve(PROJECT_DIR, "app");
1111

1212
function install() {

npmScriptsManager.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const DEPRECATED_SCRIPT_TEMPLATES = Object.freeze([
1111
"prewebpack-[PLATFORM]",
1212
"webpack-[PLATFORM]",
1313
"prestart-[PLATFORM]-bundle",
14-
"start-[PLATFORM]-bundle",
1514
"prebuild-[PLATFORM]-bundle",
16-
"build-[PLATFORM]-bundle",
1715
]);
1816

1917
const PLATFORMS = Object.freeze(["android", "ios"]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-dev-webpack",
3-
"version": "0.7.3",
3+
"version": "0.8.0",
44
"main": "index",
55
"description": "",
66
"homepage": "http://www.telerik.com",

prepublish/common/exports.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ module.exports = env => {
4444
alias: {
4545
'~': resolve("./app")
4646
},
47+
48+
// This will not follow symlinks to their original location,
49+
// and will enable us to work with symlinked packages during development.
50+
symlinks: false
51+
},
52+
resolveLoader: {
53+
// This will not follow symlinks to their original location,
54+
// and will enable us to work with symlinked loader packages during development.
55+
symlinks: false
4756
},
4857
node: {
4958
// Disable node shims that conflict with NativeScript

prepublish/common/imports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const ExtractTextPlugin = require("extract-text-webpack-plugin");
88
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
9+
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
910
`;

prepublish/common/plugins.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module.exports = `
2626
"./vendor",
2727
"./bundle",
2828
]),
29+
30+
// Support for web workers since v3.2
31+
new NativeScriptWorkerPlugin(),
2932
3033
// Generate report files for bundles content
3134
new BundleAnalyzerPlugin({

projectHelpers.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,36 @@ const writePackageJson = (content, projectDir) => {
3030
fs.writeFileSync(packageJsonPath, JSON.stringify(content, null, 2))
3131
}
3232

33+
const getProjectDir = ({ nestingLvl } = { nestingLvl: 0 }) => {
34+
// INIT_CWD is available since npm 5.4
35+
const initCwd = process.env.INIT_CWD;
36+
const shouldUseInitCwd = (() => {
37+
if (!initCwd) {
38+
return false;
39+
}
40+
41+
const installedPackage = path.resolve(initCwd, "node_modules", "nativescript-dev-webpack");
42+
if (!fs.existsSync(installedPackage)) {
43+
return false;
44+
}
45+
46+
const stat = fs.lstatSync(installedPackage);
47+
return stat.isSymbolicLink();
48+
})();
49+
50+
return shouldUseInitCwd ?
51+
initCwd :
52+
Array
53+
.from(Array(nestingLvl))
54+
.reduce(dir => path.dirname(dir), __dirname);
55+
};
56+
3357
const getPackageJsonPath = projectDir => path.resolve(projectDir, "package.json");
3458

3559
module.exports = {
3660
isTypeScript,
3761
isAngular,
38-
getPackageJson,
3962
writePackageJson,
63+
getPackageJson,
64+
getProjectDir,
4065
};

templates/webpack.angular.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target
77
const CopyWebpackPlugin = require("copy-webpack-plugin");
88
const ExtractTextPlugin = require("extract-text-webpack-plugin");
99
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
10+
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
1011

1112
const { AotPlugin } = require("@ngtools/webpack");
1213

@@ -59,6 +60,15 @@ module.exports = env => {
5960
alias: {
6061
'~': resolve("./app")
6162
},
63+
64+
// This will not follow symlinks to their original location,
65+
// and will enable us to work with symlinked packages during development.
66+
symlinks: false
67+
},
68+
resolveLoader: {
69+
// This will not follow symlinks to their original location,
70+
// and will enable us to work with symlinked loader packages during development.
71+
symlinks: false
6272
},
6373
node: {
6474
// Disable node shims that conflict with NativeScript
@@ -184,6 +194,9 @@ function getPlugins(platform, env) {
184194
"./vendor",
185195
"./bundle",
186196
]),
197+
198+
// Support for web workers since v3.2
199+
new NativeScriptWorkerPlugin(),
187200

188201
// Generate report files for bundles content
189202
new BundleAnalyzerPlugin({

templates/webpack.javascript.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target
77
const CopyWebpackPlugin = require("copy-webpack-plugin");
88
const ExtractTextPlugin = require("extract-text-webpack-plugin");
99
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
10+
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
1011

1112

1213
let mainSheet = '';
@@ -56,6 +57,15 @@ module.exports = env => {
5657
alias: {
5758
'~': resolve("./app")
5859
},
60+
61+
// This will not follow symlinks to their original location,
62+
// and will enable us to work with symlinked packages during development.
63+
symlinks: false
64+
},
65+
resolveLoader: {
66+
// This will not follow symlinks to their original location,
67+
// and will enable us to work with symlinked loader packages during development.
68+
symlinks: false
5969
},
6070
node: {
6171
// Disable node shims that conflict with NativeScript
@@ -168,6 +178,9 @@ function getPlugins(platform, env) {
168178
"./vendor",
169179
"./bundle",
170180
]),
181+
182+
// Support for web workers since v3.2
183+
new NativeScriptWorkerPlugin(),
171184

172185
// Generate report files for bundles content
173186
new BundleAnalyzerPlugin({

templates/webpack.typescript.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target
77
const CopyWebpackPlugin = require("copy-webpack-plugin");
88
const ExtractTextPlugin = require("extract-text-webpack-plugin");
99
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
10+
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
1011

1112

1213
let mainSheet = '';
@@ -56,6 +57,15 @@ module.exports = env => {
5657
alias: {
5758
'~': resolve("./app")
5859
},
60+
61+
// This will not follow symlinks to their original location,
62+
// and will enable us to work with symlinked packages during development.
63+
symlinks: false
64+
},
65+
resolveLoader: {
66+
// This will not follow symlinks to their original location,
67+
// and will enable us to work with symlinked loader packages during development.
68+
symlinks: false
5969
},
6070
node: {
6171
// Disable node shims that conflict with NativeScript
@@ -177,6 +187,9 @@ function getPlugins(platform, env) {
177187
"./vendor",
178188
"./bundle",
179189
]),
190+
191+
// Support for web workers since v3.2
192+
new NativeScriptWorkerPlugin(),
180193

181194
// Generate report files for bundles content
182195
new BundleAnalyzerPlugin({

0 commit comments

Comments
 (0)