app-bundler 0.2.11 → 0.2.13

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.
package/lib/bundler.js CHANGED
@@ -7877,7 +7877,7 @@ class DataInliner extends BaseRewriter_1.BaseRewriter {
7877
7877
  await this.rewriteImport(resource, res);
7878
7878
  continue;
7879
7879
  }
7880
- console.error('CJS not implemented');
7880
+ await this.rewriteRequire(resource, res);
7881
7881
  }
7882
7882
  }
7883
7883
  accepts(type) {
@@ -7902,6 +7902,24 @@ class DataInliner extends BaseRewriter_1.BaseRewriter {
7902
7902
  resource.dependencies.splice(i, 1);
7903
7903
  this.solution.outputResources.remove(dep.resource);
7904
7904
  }
7905
+ rewriteRequire(resource, dep) {
7906
+ let rgx = new RegExp(`require\\s*\\(\\s*['"]${dep.url}['"]\\s*\\)\\s*;?`);
7907
+ let match = rgx.exec(resource.content);
7908
+ if (match == null) {
7909
+ console.error(`No require found for ${dep.url} in ${resource.filename}`);
7910
+ return;
7911
+ }
7912
+ let json = dep.resource.content;
7913
+ if (typeof json !== 'string') {
7914
+ json = JSON.stringify(json);
7915
+ }
7916
+ let code = `${json}`;
7917
+ let content = resource.content.replace(match[0], code);
7918
+ resource.content = content;
7919
+ let i = resource.dependencies.indexOf(dep);
7920
+ resource.dependencies.splice(i, 1);
7921
+ this.solution.outputResources.remove(dep.resource);
7922
+ }
7905
7923
  }
7906
7924
  exports.DataInliner = DataInliner;
7907
7925
  ;
package/lib/cli.js CHANGED
@@ -7879,7 +7879,7 @@ class DataInliner extends BaseRewriter_1.BaseRewriter {
7879
7879
  await this.rewriteImport(resource, res);
7880
7880
  continue;
7881
7881
  }
7882
- console.error('CJS not implemented');
7882
+ await this.rewriteRequire(resource, res);
7883
7883
  }
7884
7884
  }
7885
7885
  accepts(type) {
@@ -7904,6 +7904,24 @@ class DataInliner extends BaseRewriter_1.BaseRewriter {
7904
7904
  resource.dependencies.splice(i, 1);
7905
7905
  this.solution.outputResources.remove(dep.resource);
7906
7906
  }
7907
+ rewriteRequire(resource, dep) {
7908
+ let rgx = new RegExp(`require\\s*\\(\\s*['"]${dep.url}['"]\\s*\\)\\s*;?`);
7909
+ let match = rgx.exec(resource.content);
7910
+ if (match == null) {
7911
+ console.error(`No require found for ${dep.url} in ${resource.filename}`);
7912
+ return;
7913
+ }
7914
+ let json = dep.resource.content;
7915
+ if (typeof json !== 'string') {
7916
+ json = JSON.stringify(json);
7917
+ }
7918
+ let code = `${json}`;
7919
+ let content = resource.content.replace(match[0], code);
7920
+ resource.content = content;
7921
+ let i = resource.dependencies.indexOf(dep);
7922
+ resource.dependencies.splice(i, 1);
7923
+ this.solution.outputResources.remove(dep.resource);
7924
+ }
7907
7925
  }
7908
7926
  exports.DataInliner = DataInliner;
7909
7927
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-bundler",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "",
5
5
  "main": "lib/bundler.js",
6
6
  "bin": {
package/tsconfig.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
 
9
9
  "outDir": "ts-temp",
10
- "lib": ["es2015", "es2015.promise", "es2016", "dom"],
10
+ "lib": ["es2018", "dom"],
11
11
  "typeRoots": [
12
12
  "node_modules/@types",
13
13
  "typings",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "types": ["node", "assertion", "atma-utest", "jquery"],
18
18
  "declaration": true,
19
- "target": "es5",
19
+ "target": "ES2018",
20
20
  "module": "commonjs",
21
21
  "sourceMap": false,
22
22
  "experimentalDecorators": true