app-bundler 0.1.5 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/bundler.js +44 -28
  2. package/lib/cli.js +44 -28
  3. package/package.json +4 -4
package/lib/bundler.js CHANGED
@@ -1285,16 +1285,19 @@ var Npm;
1285
1285
  function resolveAppUrl(path, currentLocation, base) {
1286
1286
  let name = /^(@?[^\\\/]+)/.exec(path)[0];
1287
1287
  let resource = path.substring(name.length + 1);
1288
- if (resource && hasExt(resource) === false) {
1289
- resource += '.js';
1290
- }
1291
1288
  while (path != null) {
1292
1289
  let dirname = (0, path_1.path_combine)(currentLocation, 'node_modules', name);
1293
1290
  let pckg = (0, path_1.path_combine)(dirname, 'package.json');
1294
1291
  if (global_1.io.File.exists(pckg)) {
1295
- let json = global_1.io.File.read(pckg);
1296
- if (json) {
1297
- let filename = combineMain(dirname, json.main);
1292
+ let main = resource;
1293
+ if (main === '') {
1294
+ let json = global_1.io.File.read(pckg);
1295
+ if (json) {
1296
+ main = json.main;
1297
+ }
1298
+ }
1299
+ if (main) {
1300
+ let filename = combineMain(dirname, main);
1298
1301
  if (base) {
1299
1302
  if (base.endsWith('/') === false) {
1300
1303
  // Base path must be a folder
@@ -1318,14 +1321,20 @@ var Npm;
1318
1321
  return null;
1319
1322
  }
1320
1323
  Npm.resolveAppUrl = resolveAppUrl;
1321
- function combineMain(cwd, filename) {
1324
+ function combineMain(directory, filename) {
1322
1325
  if (filename == null) {
1323
1326
  filename = 'index.js';
1324
1327
  }
1325
- if (hasExt(filename) === false) {
1326
- filename += '.js';
1328
+ let path = (0, path_1.path_combine)(directory, filename);
1329
+ if (hasExt(path) === false) {
1330
+ let likelyTs = path.includes('/src/');
1331
+ if (likelyTs) {
1332
+ if (global_1.io.File.exists(path + '.ts')) {
1333
+ return path + '.ts';
1334
+ }
1335
+ }
1336
+ path += '.js';
1327
1337
  }
1328
- var path = (0, path_1.path_combine)(cwd, filename);
1329
1338
  if (global_1.io.File.exists(path)) {
1330
1339
  return path;
1331
1340
  }
@@ -2593,7 +2602,7 @@ class SolutionOpts extends SolutionOptsBase {
2593
2602
  varDefs: null,
2594
2603
  parserIgnoreDependencies: [
2595
2604
  '\\/bower_components\\/',
2596
- '\\/node_modules\\/',
2605
+ '\\/node_modules\\/(?!.+\\.ts\\b)',
2597
2606
  '\\.min\\.'
2598
2607
  ],
2599
2608
  dynamicDependencies: [],
@@ -5285,9 +5294,9 @@ class CommonJsPathResolver extends BasePathResolver_1.BasePathResolver {
5285
5294
  return true;
5286
5295
  }
5287
5296
  resolve(includeData, parentResource) {
5288
- var filename = nodeModuleResolve(includeData.url, parentResource.directory);
5297
+ let filename = nodeModuleResolve(includeData.url, parentResource.directory);
5289
5298
  if (filename) {
5290
- var url = this.solution.opts.toAppUrl(filename);
5299
+ let url = this.solution.opts.toAppUrl(filename);
5291
5300
  this.solution.opts.mappings[includeData.url] = url;
5292
5301
  }
5293
5302
  return filename;
@@ -5302,32 +5311,39 @@ const nodeCoreModules = [
5302
5311
  'tls', 'tty', 'url', 'util', 'vm', 'zlib'
5303
5312
  ];
5304
5313
  function nodeModuleResolve(path, location_) {
5305
- var location = location_.replace(/[\\\/]+$/, '');
5306
- var name = /^([\w\-]+)/.exec(path)[0];
5307
- var resource = path.substring(name.length + 1);
5308
- if (resource && hasExt(resource) === false) {
5309
- resource += '.js';
5310
- }
5311
- var current = location;
5312
- var root_ = current + '/node_modules/' + name + '/';
5314
+ let location = location_.replace(/[\\\/]+$/, '');
5315
+ let name = /^([\w\-]+)/.exec(path)[0];
5316
+ let resource = path.substring(name.length + 1);
5317
+ let current = location;
5318
+ let root_ = current + '/node_modules/' + name + '/';
5313
5319
  while (true) {
5314
- var nodeModules = (0, path_1.path_combine)(current, '/node_modules/' + name + '/');
5315
- var pckg = nodeModules + 'package.json';
5320
+ let nodeModules = (0, path_1.path_combine)(current, '/node_modules/' + name + '/');
5321
+ let pckg = nodeModules + 'package.json';
5316
5322
  if (global_1.io.File.exists(pckg) === false) {
5317
- var next = current.replace(/[^\/\\]+[\/\\]?$/, '');
5323
+ let next = current.replace(/[^\/\\]+[\/\\]?$/, '');
5318
5324
  if (next === current) {
5319
5325
  return root_ + 'package.json';
5320
5326
  }
5321
5327
  current = next;
5322
5328
  continue;
5323
5329
  }
5324
- var json = global_1.io.File.read(pckg);
5330
+ if (resource) {
5331
+ let path = nodeModules + resource;
5332
+ if (hasExt(path) === false) {
5333
+ let likelyTs = path.includes('/src/');
5334
+ if (likelyTs) {
5335
+ if (global_1.io.File.exists(path + '.ts')) {
5336
+ return path + '.ts';
5337
+ }
5338
+ }
5339
+ return path + '.js';
5340
+ }
5341
+ return path;
5342
+ }
5343
+ let json = global_1.io.File.read(pckg);
5325
5344
  if (typeof json === 'string') {
5326
5345
  json = JSON.parse(json);
5327
5346
  }
5328
- if (resource) {
5329
- return nodeModules + resource;
5330
- }
5331
5347
  if (json.main) {
5332
5348
  return (0, path_1.path_combine)(nodeModules, json.main);
5333
5349
  }
package/lib/cli.js CHANGED
@@ -1287,16 +1287,19 @@ var Npm;
1287
1287
  function resolveAppUrl(path, currentLocation, base) {
1288
1288
  let name = /^(@?[^\\\/]+)/.exec(path)[0];
1289
1289
  let resource = path.substring(name.length + 1);
1290
- if (resource && hasExt(resource) === false) {
1291
- resource += '.js';
1292
- }
1293
1290
  while (path != null) {
1294
1291
  let dirname = (0, path_1.path_combine)(currentLocation, 'node_modules', name);
1295
1292
  let pckg = (0, path_1.path_combine)(dirname, 'package.json');
1296
1293
  if (global_1.io.File.exists(pckg)) {
1297
- let json = global_1.io.File.read(pckg);
1298
- if (json) {
1299
- let filename = combineMain(dirname, json.main);
1294
+ let main = resource;
1295
+ if (main === '') {
1296
+ let json = global_1.io.File.read(pckg);
1297
+ if (json) {
1298
+ main = json.main;
1299
+ }
1300
+ }
1301
+ if (main) {
1302
+ let filename = combineMain(dirname, main);
1300
1303
  if (base) {
1301
1304
  if (base.endsWith('/') === false) {
1302
1305
  // Base path must be a folder
@@ -1320,14 +1323,20 @@ var Npm;
1320
1323
  return null;
1321
1324
  }
1322
1325
  Npm.resolveAppUrl = resolveAppUrl;
1323
- function combineMain(cwd, filename) {
1326
+ function combineMain(directory, filename) {
1324
1327
  if (filename == null) {
1325
1328
  filename = 'index.js';
1326
1329
  }
1327
- if (hasExt(filename) === false) {
1328
- filename += '.js';
1330
+ let path = (0, path_1.path_combine)(directory, filename);
1331
+ if (hasExt(path) === false) {
1332
+ let likelyTs = path.includes('/src/');
1333
+ if (likelyTs) {
1334
+ if (global_1.io.File.exists(path + '.ts')) {
1335
+ return path + '.ts';
1336
+ }
1337
+ }
1338
+ path += '.js';
1329
1339
  }
1330
- var path = (0, path_1.path_combine)(cwd, filename);
1331
1340
  if (global_1.io.File.exists(path)) {
1332
1341
  return path;
1333
1342
  }
@@ -2595,7 +2604,7 @@ class SolutionOpts extends SolutionOptsBase {
2595
2604
  varDefs: null,
2596
2605
  parserIgnoreDependencies: [
2597
2606
  '\\/bower_components\\/',
2598
- '\\/node_modules\\/',
2607
+ '\\/node_modules\\/(?!.+\\.ts\\b)',
2599
2608
  '\\.min\\.'
2600
2609
  ],
2601
2610
  dynamicDependencies: [],
@@ -5287,9 +5296,9 @@ class CommonJsPathResolver extends BasePathResolver_1.BasePathResolver {
5287
5296
  return true;
5288
5297
  }
5289
5298
  resolve(includeData, parentResource) {
5290
- var filename = nodeModuleResolve(includeData.url, parentResource.directory);
5299
+ let filename = nodeModuleResolve(includeData.url, parentResource.directory);
5291
5300
  if (filename) {
5292
- var url = this.solution.opts.toAppUrl(filename);
5301
+ let url = this.solution.opts.toAppUrl(filename);
5293
5302
  this.solution.opts.mappings[includeData.url] = url;
5294
5303
  }
5295
5304
  return filename;
@@ -5304,32 +5313,39 @@ const nodeCoreModules = [
5304
5313
  'tls', 'tty', 'url', 'util', 'vm', 'zlib'
5305
5314
  ];
5306
5315
  function nodeModuleResolve(path, location_) {
5307
- var location = location_.replace(/[\\\/]+$/, '');
5308
- var name = /^([\w\-]+)/.exec(path)[0];
5309
- var resource = path.substring(name.length + 1);
5310
- if (resource && hasExt(resource) === false) {
5311
- resource += '.js';
5312
- }
5313
- var current = location;
5314
- var root_ = current + '/node_modules/' + name + '/';
5316
+ let location = location_.replace(/[\\\/]+$/, '');
5317
+ let name = /^([\w\-]+)/.exec(path)[0];
5318
+ let resource = path.substring(name.length + 1);
5319
+ let current = location;
5320
+ let root_ = current + '/node_modules/' + name + '/';
5315
5321
  while (true) {
5316
- var nodeModules = (0, path_1.path_combine)(current, '/node_modules/' + name + '/');
5317
- var pckg = nodeModules + 'package.json';
5322
+ let nodeModules = (0, path_1.path_combine)(current, '/node_modules/' + name + '/');
5323
+ let pckg = nodeModules + 'package.json';
5318
5324
  if (global_1.io.File.exists(pckg) === false) {
5319
- var next = current.replace(/[^\/\\]+[\/\\]?$/, '');
5325
+ let next = current.replace(/[^\/\\]+[\/\\]?$/, '');
5320
5326
  if (next === current) {
5321
5327
  return root_ + 'package.json';
5322
5328
  }
5323
5329
  current = next;
5324
5330
  continue;
5325
5331
  }
5326
- var json = global_1.io.File.read(pckg);
5332
+ if (resource) {
5333
+ let path = nodeModules + resource;
5334
+ if (hasExt(path) === false) {
5335
+ let likelyTs = path.includes('/src/');
5336
+ if (likelyTs) {
5337
+ if (global_1.io.File.exists(path + '.ts')) {
5338
+ return path + '.ts';
5339
+ }
5340
+ }
5341
+ return path + '.js';
5342
+ }
5343
+ return path;
5344
+ }
5345
+ let json = global_1.io.File.read(pckg);
5327
5346
  if (typeof json === 'string') {
5328
5347
  json = JSON.parse(json);
5329
5348
  }
5330
- if (resource) {
5331
- return nodeModules + resource;
5332
- }
5333
5349
  if (json.main) {
5334
5350
  return (0, path_1.path_combine)(nodeModules, json.main);
5335
5351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-bundler",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "main": "lib/bundler.js",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "homepage": "https://github.com/atmajs/app-bundler",
35
35
  "dependencies": {
36
- "alot": "^0.2.99",
36
+ "alot": "^0.3.0",
37
37
  "appcfg": "^0.4.64",
38
38
  "atma-class": "^1.1.83",
39
39
  "atma-io": "^1.2.60",
@@ -42,8 +42,8 @@
42
42
  "atma-utils": "^0.1.13",
43
43
  "axios": "^0.21.0",
44
44
  "cheerio": "^0.20.0",
45
- "includejs": "^0.16.3",
46
- "maskjs": "^0.72.36",
45
+ "includejs": "^0.16.7",
46
+ "maskjs": "^0.72.37",
47
47
  "memd": "^0.3.10",
48
48
  "uglify-js": "^3.13.10"
49
49
  },