├── .gitignore ├── LICENSE ├── README.md ├── rules ├── BUILD ├── WORKSPACE ├── def.bzl └── private │ ├── BUILD │ ├── generate_tsconfig_json.js │ ├── rollup_js_result.bzl │ ├── rollup_js_source_bundle.bzl │ ├── rollup_js_vendor_bundle.bzl │ ├── ts_results.bzl │ ├── tsc.bzl │ ├── typings.bzl │ └── uglify_es.bzl └── scenarios ├── 01_single ├── BUILD └── square.ts ├── 02_dependent ├── BUILD ├── basics │ ├── BUILD │ ├── math.ts │ └── point2d.ts ├── polygon │ ├── BUILD │ ├── hexagon.ts │ ├── polygon.ts │ └── triangle.ts └── prism │ ├── BUILD │ ├── hexagonal-prism.ts │ ├── point3d.ts │ └── triangular-prism.ts ├── 03_single_npm_dep ├── BUILD └── long-gen │ ├── BUILD │ └── long-gen.ts ├── 04_external_deps ├── BUILD ├── long-gen │ ├── BUILD │ └── long-gen.ts └── print-timestamp │ ├── BUILD │ └── print-timestamp.ts ├── 05_compile_ts_out └── BUILD ├── 06_typings ├── ts_src │ ├── BUILD │ └── square.ts └── typings │ ├── BUILD │ └── shape.d.ts ├── BUILD ├── WORKSPACE ├── index01.html ├── index02.html ├── index03.html ├── index04-min.html ├── index04.html ├── index05.html ├── package-lock.json ├── package.json ├── rollupjs_experiment ├── bar.js ├── index.html ├── rollup-source.js ├── rollup-vendor.js └── vendor.js └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bazel-* 3 | node_modules.zip 4 | dist/ 5 | .idea 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Please read [this post](https://github.com/Microsoft/TypeScript/issues/13538#issuecomment-293219979). 2 | 3 | Provides a single key rule, `tsc`, which allows a typescript project to be split into small libraries, and for those libraries to be independently compiled. 4 | 5 | In contrast to [rules_typescript](https://github.com/bazelbuild/rules_typescript), it depends on a few core bazel rules and has no other dependencies. You plug in your own nodejs executable, tsc implementation, and tsconfig.json. 6 | 7 | Comes with bonus rules for creating and minifying js bundles, from the results of tsc compilation. All sourcemaps contain original typescript source code. 8 | 9 | ## Installation 10 | 11 | TODO 12 | 13 | ## Example usage 14 | 15 | ```python 16 | load("@rules_multi_tsc//:def.bzl", "tsc") 17 | 18 | tsc( 19 | name="tsc", 20 | ts_path="polygon", 21 | srcs=glob(["*.ts"]), 22 | deps=["//02_dependent/basics:tsc"], 23 | 24 | node_executable="@node//:bin/node", 25 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 26 | tsconfig_json="//:tsconfig.json", 27 | ) 28 | ``` 29 | 30 | This example compiles .ts files in the current directory, 31 | and makes associated typescript definitions available at the `polygon` path, e.g.: 32 | 33 | ```typescript 34 | import {Hexagon} from "polygon/hexagon" 35 | ``` 36 | 37 | Please see the [scenarios](./scenarios) directory for more examples. -------------------------------------------------------------------------------- /rules/BUILD: -------------------------------------------------------------------------------- 1 | # empty -------------------------------------------------------------------------------- /rules/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name="rules_multi_tsc") -------------------------------------------------------------------------------- /rules/def.bzl: -------------------------------------------------------------------------------- 1 | load("//private:tsc.bzl", _tsc = "tsc") 2 | load("//private:typings.bzl", _typings = "typings") 3 | load("//private:rollup_js_source_bundle.bzl", _rollup_js_source_bundle = "rollup_js_source_bundle") 4 | load("//private:rollup_js_vendor_bundle.bzl", _rollup_js_vendor_bundle = "rollup_js_vendor_bundle") 5 | load("//private:uglify_es.bzl", _uglify_es = "uglify_es") 6 | 7 | 8 | tsc = _tsc 9 | rollup_js_source_bundle = _rollup_js_source_bundle 10 | rollup_js_vendor_bundle = _rollup_js_vendor_bundle 11 | typings = _typings 12 | uglify_es = _uglify_es 13 | -------------------------------------------------------------------------------- /rules/private/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//private:__subpackages__"]) 2 | 3 | exports_files(["generate_tsconfig_json.js"]) -------------------------------------------------------------------------------- /rules/private/generate_tsconfig_json.js: -------------------------------------------------------------------------------- 1 | const assert = require("assert") 2 | const fs = require("fs") 3 | const path = require('path') 4 | 5 | assert(process.argv.length==3 && fs.existsSync(process.argv[2]), `input to tsconfig generator not found. argv: ${process.argv}`) 6 | 7 | const inputFile = process.argv[2] 8 | 9 | const inputJson = JSON.parse(fs.readFileSync(inputFile, "utf8")) 10 | 11 | var tsconfigJson = null 12 | try { 13 | tsconfigJson = JSON.parse(fs.readFileSync(inputJson["tsconfig_template_json_file"], "utf8")) 14 | } catch (error) { 15 | console.error(`Error occurred while attempting to parse ${inputJson["tsconfig_template_json_file"]}`, error) 16 | process.exit(1) 17 | } 18 | 19 | if (tsconfigJson["compilerOptions"] == null) { 20 | tsconfigJson["compilerOptions"] = {} 21 | } 22 | 23 | tsconfigJson["compilerOptions"]["declaration"] = true // force always generating .d.ts files 24 | tsconfigJson["compilerOptions"]["sourceMap"] = true // force always generating sourcemaps 25 | tsconfigJson["compilerOptions"]["inlineSources"] = true // always include the original ts source in the sourcemap 26 | tsconfigJson["compilerOptions"]["outDir"] = inputJson["out_dir"] 27 | tsconfigJson["compilerOptions"]["paths"] = inputJson["paths_mapping"] 28 | 29 | 30 | tsconfigJson["files"] = inputJson["srcs"] 31 | 32 | process.stdout.write(JSON.stringify(tsconfigJson, null, " ")) -------------------------------------------------------------------------------- /rules/private/rollup_js_result.bzl: -------------------------------------------------------------------------------- 1 | RollupJsResult = provider( 2 | fields = [ 3 | "js_file", 4 | "sourcemap_file", 5 | ] 6 | ) 7 | -------------------------------------------------------------------------------- /rules/private/rollup_js_source_bundle.bzl: -------------------------------------------------------------------------------- 1 | load(":tsc.bzl", "CumulativeJsResult") 2 | load(":rollup_js_result.bzl", "RollupJsResult") 3 | 4 | def _impl(ctx): 5 | node_executable = ctx.attr.node_executable.files.to_list()[0] 6 | rollup_script = ctx.attr.rollup_script.files.to_list()[0] 7 | node_modules_path = rollup_script.path.split("/node_modules/")[0] + "/node_modules" 8 | entrypoint_js_content = ctx.attr.entrypoint_js_content # TODO: must specify if source or all type 9 | module_name = ctx.attr.module_name 10 | tsc_dep = ctx.attr.tsc_dep 11 | module_globals = ctx.attr.globals 12 | 13 | entrypoint_js_file = ctx.actions.declare_file("%s-entrypoint.js" % module_name) 14 | 15 | if CumulativeJsResult not in tsc_dep: 16 | fail("tsc_dep must be a tsc target") 17 | 18 | ctx.actions.write( 19 | output=entrypoint_js_file, 20 | content=entrypoint_js_content) 21 | 22 | cumulative_js_result = tsc_dep[CumulativeJsResult] 23 | inputs = cumulative_js_result.js_and_sourcemap_files 24 | ts_path_to_js_dir = cumulative_js_result.ts_path_to_js_dir 25 | if ts_path_to_js_dir == None: 26 | ts_path_to_js_dir = {} 27 | 28 | alias_entries = [] 29 | for ts_path in ts_path_to_js_dir: 30 | alias_entries.append("'%s' : path.resolve(process.cwd(), './%s')" % (ts_path, ts_path_to_js_dir[ts_path])) 31 | alias_str = "{\n" + ",\n".join(alias_entries) + "}\n" 32 | 33 | dest_file = ctx.actions.declare_file(module_name + ".js") 34 | sourcemap_file = ctx.actions.declare_file(module_name + ".js.map") 35 | 36 | globals_config = "" 37 | externals_config = "" 38 | if (len(module_globals)>0): 39 | externals_entries = [] 40 | for k in module_globals.keys(): 41 | externals_entries.append("'%s'" % k) 42 | externals_config = """ 43 | external: [ 44 | %s 45 | ], 46 | """ % ",\n".join(externals_entries) 47 | 48 | globals_entries = [] 49 | for global_name in module_globals: 50 | globals_entries.append("'%s': '%s'" % (global_name, module_globals[global_name])) 51 | globals_config = ", globals: {\n" + ",\n".join(globals_entries) + "}\n" 52 | 53 | 54 | rollup_config_content = """ 55 | const path = require('path'); 56 | import alias from 'rollup-plugin-alias'; 57 | import commonjs from 'rollup-plugin-commonjs'; 58 | import sourcemaps from 'rollup-plugin-sourcemaps'; 59 | 60 | export default { 61 | input: '%s', 62 | output: { 63 | file: '%s', 64 | format: 'iife', 65 | sourcemap: true, 66 | sourcemapFile: '%s', 67 | name: '%s', 68 | intro: 'const global = window' 69 | %s 70 | }, 71 | %s 72 | plugins: [ 73 | sourcemaps(), 74 | alias( 75 | %s 76 | ), 77 | commonjs() 78 | ], 79 | onwarn(warning) { 80 | if (['UNRESOLVED_IMPORT', 'MISSING_GLOBAL_NAME'].indexOf(warning.code)>=0) { 81 | console.error(warning.message) 82 | process.exit(1) 83 | } else { 84 | console.warn(warning.message) 85 | } 86 | } 87 | 88 | }; 89 | """ % ( 90 | entrypoint_js_file.path, 91 | dest_file.path, 92 | sourcemap_file.path, 93 | module_name, 94 | globals_config, 95 | externals_config, 96 | alias_str 97 | ) 98 | 99 | rollup_config_file = ctx.actions.declare_file("%s-rollup-config.js" % module_name) 100 | ctx.actions.write( 101 | output=rollup_config_file, 102 | content=rollup_config_content) 103 | 104 | ctx.actions.run_shell( 105 | command="ln -s %s node_modules;env NODE_PATH=node_modules %s %s -c %s" % ( 106 | node_modules_path, 107 | node_executable.path, 108 | rollup_script.path, 109 | rollup_config_file.path, 110 | ), 111 | inputs=inputs, 112 | outputs = [dest_file, sourcemap_file], 113 | progress_message = "running rollup js '%s'..." % module_name, 114 | tools = [ 115 | node_executable, 116 | rollup_script, 117 | rollup_config_file, 118 | entrypoint_js_file, 119 | ] + ctx.attr.rollup_plugins.files.to_list() 120 | ) 121 | 122 | return [ 123 | DefaultInfo(files=depset([dest_file, sourcemap_file])), 124 | RollupJsResult(js_file=dest_file, sourcemap_file=sourcemap_file), 125 | ] 126 | 127 | rollup_js_source_bundle = rule( 128 | implementation = _impl, 129 | 130 | attrs = { 131 | "entrypoint_js_content": attr.string(), 132 | "module_name": attr.string(mandatory=True), 133 | 134 | "tsc_dep": attr.label(), 135 | "globals": attr.string_dict(), 136 | 137 | "node_executable": attr.label(allow_files=True, mandatory=True), 138 | "rollup_script": attr.label(allow_files=True, mandatory=True), 139 | "rollup_plugins": attr.label(mandatory=True), 140 | } 141 | ) 142 | -------------------------------------------------------------------------------- /rules/private/rollup_js_vendor_bundle.bzl: -------------------------------------------------------------------------------- 1 | load(":rollup_js_result.bzl", "RollupJsResult") 2 | 3 | def _impl(ctx): 4 | node_executable = ctx.attr.node_executable.files.to_list()[0] 5 | rollup_script = ctx.attr.rollup_script.files.to_list()[0] 6 | module_name = ctx.attr.module_name 7 | node_modules_path = rollup_script.path.split("/node_modules/")[0] + "/node_modules" 8 | exports = ctx.attr.exports 9 | 10 | dep_files = [] 11 | for d in ctx.attr.deps: 12 | dep_files.extend(d.files.to_list()) 13 | 14 | entrypoint_js_file = ctx.actions.declare_file("%s-entrypoint.js" % module_name) 15 | 16 | vendor_import_entries = [] 17 | for export_name in exports: 18 | vendor_import_entries.append("import * as %s from '%s'" % (exports[export_name], export_name)) 19 | 20 | vendor_entrypoint_content = \ 21 | "\n".join(vendor_import_entries) + \ 22 | "\n\n" + \ 23 | "export default {\n" + \ 24 | ",\n".join(exports.values()) + \ 25 | "}\n" 26 | 27 | ctx.actions.write( 28 | output=entrypoint_js_file, 29 | content=vendor_entrypoint_content) 30 | 31 | dest_file = ctx.actions.declare_file(module_name + ".js") 32 | sourcemap_file = ctx.actions.declare_file(module_name + ".js.map") 33 | 34 | # transitive deps are not properly imported without the includePaths fix, detailed here: 35 | # https://github.com/rollup/rollup-plugin-node-resolve/issues/105#issuecomment-332640015 36 | 37 | rollup_config_content = """ 38 | const path = require('path'); 39 | import commonjs from 'rollup-plugin-commonjs'; 40 | import resolve from 'rollup-plugin-node-resolve'; 41 | import includePaths from 'rollup-plugin-includepaths'; 42 | import sourcemaps from 'rollup-plugin-sourcemaps'; 43 | import replace from 'rollup-plugin-replace' 44 | 45 | export default { 46 | input: '%s', 47 | output: { 48 | file: '%s', 49 | format: 'iife', 50 | sourcemap: true, 51 | sourcemapFile: '%s', 52 | name: '%s', 53 | intro: 'const global = window' 54 | }, 55 | plugins: [ 56 | sourcemaps(), 57 | resolve({ 58 | preferBuiltins: false, 59 | }), 60 | commonjs(), 61 | replace({ 62 | "process.env.NODE_ENV": JSON.stringify( "production" ) 63 | }) 64 | ], 65 | onwarn(warning) { 66 | if (['UNRESOLVED_IMPORT', 'MISSING_GLOBAL_NAME'].indexOf(warning.code)>=0) { 67 | console.error(warning.message) 68 | process.exit(1) 69 | } else { 70 | console.warn(warning.message) 71 | } 72 | } 73 | 74 | }; 75 | """ % ( 76 | entrypoint_js_file.path, 77 | dest_file.path, 78 | sourcemap_file.path, 79 | module_name, 80 | ) 81 | 82 | rollup_config_file = ctx.actions.declare_file("%s-rollup-config.js" % module_name) 83 | ctx.actions.write( 84 | output=rollup_config_file, 85 | content=rollup_config_content) 86 | 87 | ctx.actions.run_shell( 88 | command="ln -s %s node_modules;env NODE_PATH=node_modules %s %s -c %s" % ( 89 | node_modules_path, 90 | node_executable.path, 91 | rollup_script.path, 92 | rollup_config_file.path, 93 | ), 94 | inputs=dep_files, 95 | outputs = [dest_file, sourcemap_file], 96 | progress_message = "running rollup js '%s'..." % module_name, 97 | tools = [ 98 | node_executable, 99 | rollup_script, 100 | rollup_config_file, 101 | entrypoint_js_file, 102 | ] + ctx.attr.rollup_plugins.files.to_list() + dep_files 103 | ) 104 | 105 | return [ 106 | DefaultInfo(files=depset([dest_file, sourcemap_file])), 107 | RollupJsResult(js_file=dest_file, sourcemap_file=sourcemap_file), 108 | ] 109 | 110 | rollup_js_vendor_bundle = rule( 111 | implementation = _impl, 112 | 113 | attrs = { 114 | "module_name": attr.string(mandatory=True), 115 | "exports": attr.string_dict(), 116 | "deps": attr.label_list(), 117 | 118 | "node_executable": attr.label(allow_files=True, mandatory=True), 119 | "rollup_script": attr.label(allow_files=True, mandatory=True), 120 | "rollup_plugins": attr.label(mandatory=True), 121 | } 122 | ) 123 | -------------------------------------------------------------------------------- /rules/private/ts_results.bzl: -------------------------------------------------------------------------------- 1 | TsLibraryResult = provider( 2 | fields = [ 3 | "ts_path", 4 | "tsc_out_dir", 5 | "ts_declaration_files", 6 | ] 7 | ) 8 | 9 | CumulativeJsResult = provider( 10 | fields = [ 11 | "ts_path_to_js_dir", 12 | "js_and_sourcemap_files", 13 | ] 14 | ) -------------------------------------------------------------------------------- /rules/private/tsc.bzl: -------------------------------------------------------------------------------- 1 | load(":ts_results.bzl", 2 | _TsLibraryResult = "TsLibraryResult", 3 | _CumulativeJsResult = "CumulativeJsResult") 4 | 5 | TsLibraryResult = _TsLibraryResult 6 | CumulativeJsResult = _CumulativeJsResult 7 | 8 | GenerateTsconfigInput = provider( 9 | fields = [ 10 | "tsconfig_template_json_file", 11 | "srcs", 12 | "out_dir", 13 | "package_relative_path", 14 | "paths_mapping", 15 | ] 16 | ) 17 | 18 | def _impl(ctx): 19 | generate_tsconfig_json_js_script = ctx.attr._generate_tsconfig_json_js.files.to_list()[0] 20 | source_root_dir = ctx.label.package # might want to make this overridable in the future 21 | tsc_script = ctx.attr.tsc_script.files.to_list()[0] 22 | node_modules_path = tsc_script.path.split("/node_modules/")[0] + "/node_modules" 23 | tsconfig_json = ctx.attr.tsconfig_json.files.to_list()[0] 24 | node_executable = ctx.attr.node_executable.files.to_list()[0] 25 | 26 | ts_path = ctx.attr.ts_path 27 | if len(ts_path) == 0: 28 | ts_path = ctx.label.package.split("/")[-1] # ts_path defaults to the package name 29 | 30 | tsc_out_dir = None 31 | 32 | if len(ctx.attr.srcs) == 0: 33 | fail("tsc rule error: srcs must have at least one item.") 34 | 35 | # for each typescript source file, 36 | # - collect up path information, to pass to the tsconfig generator script 37 | # - collect up expected tsc outputs 38 | tsc_outputs = [] 39 | ts_declaration_outputs = [] 40 | js_and_sourcemap_outputs = [] 41 | src_file_paths = [] 42 | src_files = [] 43 | for src in ctx.attr.srcs: 44 | for src_f in src.files.to_list(): 45 | src_file_paths.append(src_f.path) 46 | src_files.append(src_f) 47 | 48 | basename_without_extension = src_f.basename.rsplit("." + src_f.extension, 1)[0] 49 | declaration_out_file = ctx.actions.declare_file("%s.d.ts" % basename_without_extension) 50 | js_out_file = ctx.actions.declare_file("%s.js" % basename_without_extension) 51 | sourcemap_out_file = ctx.actions.declare_file("%s.js.map" % basename_without_extension) 52 | 53 | bazel_out_root_dir = declaration_out_file.dirname.split(ctx.label.package)[0] 54 | tsc_out_dir = bazel_out_root_dir + ctx.label.package 55 | 56 | ts_declaration_outputs.append(declaration_out_file) 57 | js_and_sourcemap_outputs.append(js_out_file) 58 | js_and_sourcemap_outputs.append(sourcemap_out_file) 59 | 60 | tsc_outputs.append(declaration_out_file) 61 | tsc_outputs.append(js_out_file) 62 | tsc_outputs.append(sourcemap_out_file) 63 | 64 | if tsc_out_dir == None: 65 | fail("tsc rule error: must be compile at least one file") 66 | 67 | 68 | # for each dependency: 69 | # - collect up all dependency files, and then make changes in these files trigger a tsc re-run 70 | # - add a tsconfig paths mapping entry for this tsc target 71 | # - add this ts_path to the cumulative paths mapping 72 | cumulative_js_result = CumulativeJsResult( 73 | ts_path_to_js_dir = {}, 74 | js_and_sourcemap_files = [] 75 | ) 76 | deps_files = [] 77 | paths_mapping = {} 78 | dependency_ts_declaration_files = [] 79 | for dep in ctx.attr.deps: 80 | for f in dep.files.to_list(): 81 | deps_files.append(f) 82 | 83 | if TsLibraryResult in dep: 84 | r = dep[TsLibraryResult] 85 | next_ts_path = r.ts_path + "/*" 86 | if next_ts_path in paths_mapping: 87 | fail("tsc rule error: ts_path '%s' apparently defined twice" % r.ts_path) 88 | paths_mapping[r.ts_path + "/*"] = [r.tsc_out_dir + "/*"] 89 | dependency_ts_declaration_files.extend(r.ts_declaration_files.to_list()) 90 | 91 | if CumulativeJsResult in dep: 92 | r = dep[CumulativeJsResult] 93 | for p in r.ts_path_to_js_dir: 94 | cumulative_js_result.ts_path_to_js_dir[p] = r.ts_path_to_js_dir[p] 95 | cumulative_js_result.js_and_sourcemap_files.extend(r.js_and_sourcemap_files) 96 | 97 | # generate a tsconfig file tailored to this tsc library, 98 | # and containing path mappings for tsc libraries that are dependencies of this target 99 | 100 | script_input_data_file = ctx.actions.declare_file("%s_generate_tsconfig_input.json" % ctx.attr.name) 101 | ctx.actions.write( 102 | output=script_input_data_file, 103 | content=GenerateTsconfigInput( 104 | tsconfig_template_json_file=tsconfig_json.path, 105 | srcs=src_file_paths, 106 | out_dir=tsc_out_dir, 107 | package_relative_path=ctx.label.package, 108 | paths_mapping=paths_mapping, 109 | ).to_json()) 110 | 111 | generated_tsconfig_json_file = ctx.actions.declare_file("%s_tsconfig.gen-initial.json" % ctx.attr.name) 112 | 113 | ts_inputs = src_files + dependency_ts_declaration_files 114 | 115 | ctx.actions.run_shell( 116 | command="%s %s %s > %s" % ( 117 | node_executable.path, 118 | generate_tsconfig_json_js_script.path, 119 | script_input_data_file.path, 120 | generated_tsconfig_json_file.path 121 | ), 122 | inputs=ts_inputs, 123 | outputs = [generated_tsconfig_json_file], 124 | progress_message = "generating tsconfig for '%s'..." % ts_path, 125 | tools = [ 126 | node_executable, 127 | generate_tsconfig_json_js_script, 128 | tsconfig_json, 129 | script_input_data_file, 130 | ] 131 | ) 132 | 133 | 134 | # execute tsc 135 | 136 | # You would think that with moduleResolution=node in tsconfig, that something like NODE_PATH 137 | # would be scanned my tsc. That's not the case, per 138 | # https://www.typescriptlang.org/docs/handbook/module-resolution.html 139 | # Instead it insists on this parent-directory-walking strategy. Sigh. 140 | # also relevant, and disapointing https://github.com/Microsoft/TypeScript/issues/8760 141 | # 142 | # So the strategy below is to just symlink to the node_modules sitting under external/ , 143 | # in a tsc-friendly location. 144 | 145 | ctx.actions.run_shell( 146 | command=" && ".join([ 147 | "cp %s %s_tsconfig.for-use.json" % (generated_tsconfig_json_file.path, ctx.attr.name), 148 | "ln -sf %s node_modules" % node_modules_path, 149 | "%s %s -p %s_tsconfig.for-use.json" % ( 150 | node_executable.path, 151 | tsc_script.path, 152 | ctx.attr.name 153 | ), 154 | ]), 155 | inputs=[generated_tsconfig_json_file] + ts_inputs, 156 | outputs = tsc_outputs, 157 | progress_message = "running tsc for '%s'..." % ts_path, 158 | tools = [ 159 | node_executable, 160 | tsc_script, 161 | ] + deps_files 162 | ) 163 | 164 | # The "additional" file is here so the action cache invalidates 165 | # when anything that is returned by this rule changes, or is important 166 | # re: the tsc run. 167 | additional_file = ctx.actions.declare_file("%s_additional_output_for_hashing" % ctx.attr.name) 168 | ctx.actions.write( 169 | output=additional_file, 170 | content="\n".join([ 171 | ts_path, 172 | tsc_out_dir, 173 | node_executable.path, 174 | tsc_script.path, 175 | ])) 176 | 177 | ts_path_to_js_dir = cumulative_js_result.ts_path_to_js_dir 178 | if ts_path in ts_path_to_js_dir: 179 | fail("tsc rule error: ts_path '%s' apparently defined twice" % ts_path) 180 | ts_path_to_js_dir[ts_path] = tsc_out_dir 181 | 182 | # The DefaultInfo result only contains files that should cause tsc libraries that 183 | # depend on this library, to recompile. That means ts declaration files - 184 | # and DOES NOT include js files. 185 | 186 | return [ 187 | DefaultInfo( 188 | files=depset([additional_file, generated_tsconfig_json_file] + \ 189 | ts_declaration_outputs + \ 190 | dependency_ts_declaration_files), 191 | runfiles=ctx.runfiles(files=ts_declaration_outputs + js_and_sourcemap_outputs) 192 | ), 193 | TsLibraryResult( 194 | ts_path=ts_path, 195 | tsc_out_dir=tsc_out_dir, 196 | ts_declaration_files=depset(ts_declaration_outputs), # note: dependency .d.ts's not propagated 197 | ), 198 | CumulativeJsResult( 199 | ts_path_to_js_dir=ts_path_to_js_dir, 200 | js_and_sourcemap_files=cumulative_js_result.js_and_sourcemap_files + js_and_sourcemap_outputs, 201 | ) 202 | ] 203 | 204 | tsc = rule( 205 | implementation = _impl, 206 | 207 | attrs = { 208 | "ts_path": attr.string(), 209 | "srcs": attr.label_list(allow_files=True, mandatory=True), 210 | "deps": attr.label_list(default=[]), 211 | 212 | "node_executable": attr.label(allow_files=True, mandatory=True), 213 | "tsc_script": attr.label(allow_files=True, mandatory=True), 214 | "tsconfig_json": attr.label(allow_files=True, mandatory=True), 215 | 216 | "_generate_tsconfig_json_js": attr.label(default=Label("//private:generate_tsconfig_json.js"), allow_single_file=True), 217 | } 218 | ) 219 | -------------------------------------------------------------------------------- /rules/private/typings.bzl: -------------------------------------------------------------------------------- 1 | load(":ts_results.bzl", "TsLibraryResult", "CumulativeJsResult") 2 | 3 | def _impl(ctx): 4 | ts_path = ctx.attr.ts_path 5 | if len(ts_path) == 0: 6 | ts_path = ctx.label.package.split("/")[-1] # ts_path defaults to the package name 7 | 8 | src_files = [] 9 | for src in ctx.attr.srcs: 10 | for src_f in src.files.to_list(): 11 | src_files.append(src_f) 12 | 13 | return [ 14 | DefaultInfo( 15 | files=depset(src_files), 16 | ), 17 | TsLibraryResult( 18 | ts_path=ts_path, 19 | tsc_out_dir=ctx.label.package, 20 | ts_declaration_files=depset(src_files), 21 | ), 22 | CumulativeJsResult( 23 | ts_path_to_js_dir={}, 24 | js_and_sourcemap_files=[], 25 | ) 26 | ] 27 | 28 | typings = rule( 29 | implementation = _impl, 30 | 31 | attrs = { 32 | "ts_path": attr.string(), 33 | "srcs": attr.label_list(allow_files=True, mandatory=True), 34 | } 35 | ) -------------------------------------------------------------------------------- /rules/private/uglify_es.bzl: -------------------------------------------------------------------------------- 1 | load(":rollup_js_result.bzl", "RollupJsResult") 2 | 3 | def _impl(ctx): 4 | node_executable = ctx.attr.node_executable.files.to_list()[0] 5 | uglify_script = ctx.attr.uglify_script.files.to_list()[0] 6 | 7 | if RollupJsResult not in ctx.attr.rollup_dep: 8 | fail("uglify es error: rollup_js_dep must be specified and must be a rollup js target") 9 | rollup_js_result = ctx.attr.rollup_dep[RollupJsResult] 10 | 11 | base_js_name = rollup_js_result.js_file.basename.rsplit(".js", 1)[0] 12 | 13 | minified_js_file = base_js_name + ".min.js" 14 | dest_file = ctx.actions.declare_file(minified_js_file) 15 | 16 | sourcemap_file_name = base_js_name + ".min.js.map" 17 | sourcemap_file = ctx.actions.declare_file(sourcemap_file_name) 18 | 19 | ctx.actions.run_shell( 20 | command=" ".join([ 21 | "%s %s --compress --mangle --timings", 22 | "--output=%s", 23 | "--source-map \"content='%s',url='%s'\"", 24 | "%s" 25 | ]) % ( 26 | node_executable.path, 27 | uglify_script.path, 28 | dest_file.path, 29 | rollup_js_result.sourcemap_file.path, 30 | sourcemap_file_name, 31 | rollup_js_result.js_file.path 32 | ), 33 | inputs=[rollup_js_result.js_file, rollup_js_result.sourcemap_file], 34 | outputs = [dest_file, sourcemap_file], 35 | progress_message = "running uglify es '%s'..." % rollup_js_result.js_file.basename, 36 | tools = [ 37 | node_executable, 38 | uglify_script, 39 | ] 40 | ) 41 | 42 | return [DefaultInfo(files=depset([dest_file, sourcemap_file]))] 43 | 44 | uglify_es = rule( 45 | implementation = _impl, 46 | 47 | attrs = { 48 | "node_executable": attr.label(allow_files=True, mandatory=True), 49 | "uglify_script": attr.label(allow_files=True, mandatory=True), 50 | 51 | "rollup_dep": attr.label(mandatory=True), 52 | } 53 | ) 54 | -------------------------------------------------------------------------------- /scenarios/01_single/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="shape", 8 | srcs=["square.ts"], 9 | 10 | node_executable="@node//:bin/node", 11 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 12 | tsconfig_json="//:tsconfig.json", 13 | ) 14 | -------------------------------------------------------------------------------- /scenarios/01_single/square.ts: -------------------------------------------------------------------------------- 1 | class Square { 2 | constructor(private sideLength: number) {} 3 | 4 | sides(): number[] { 5 | return [this.sideLength, this.sideLength, this.sideLength, this.sideLength] 6 | } 7 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "rollup_js_source_bundle") 4 | 5 | # Note that because we only make use of hexagonal prism at the entrypoint, 6 | # no triangle-related code is included in the bundle. 7 | 8 | rollup_js_source_bundle( 9 | name="hexagonal_prism_bundle", 10 | entrypoint_js_content="const x = require('prism/hexagonal-prism'); console.log(new x.HexagonalPrism(7, 20))", 11 | module_name="hexagonalPrism", 12 | tsc_dep="//02_dependent/prism:tsc", 13 | 14 | node_executable="@node//:bin/node", 15 | rollup_script="@node_modules_archive//:node_modules/rollup/bin/rollup", 16 | rollup_plugins="@node_modules_archive//:rollup_plugins", 17 | ) 18 | -------------------------------------------------------------------------------- /scenarios/02_dependent/basics/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="basics", 8 | srcs=glob(["*.ts"]), 9 | 10 | node_executable="@node//:bin/node", 11 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 12 | tsconfig_json="//:tsconfig.json", 13 | ) 14 | -------------------------------------------------------------------------------- /scenarios/02_dependent/basics/math.ts: -------------------------------------------------------------------------------- 1 | 2 | export const SIN_60 = 0.8660 3 | export const COS_60 = 0.5 4 | // adding a non-exported const will only cause 'basics' to recompile 5 | // adding an exported const will cause all modules to recompile -------------------------------------------------------------------------------- /scenarios/02_dependent/basics/point2d.ts: -------------------------------------------------------------------------------- 1 | export class Point2d { 2 | constructor( 3 | public readonly x: number, 4 | public readonly y: number 5 | ){} 6 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/polygon/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="polygon", 8 | srcs=glob(["*.ts"]), 9 | deps=["//02_dependent/basics:tsc"], 10 | 11 | node_executable="@node//:bin/node", 12 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 13 | tsconfig_json="//:tsconfig.json", 14 | ) 15 | -------------------------------------------------------------------------------- /scenarios/02_dependent/polygon/hexagon.ts: -------------------------------------------------------------------------------- 1 | import {Point2d} from "basics/point2d" 2 | import {SIN_60, COS_60} from "basics/math" 3 | import {Polygon} from "./polygon" 4 | 5 | export class Hexagon implements Polygon { 6 | constructor(private sideLength: number) {} 7 | 8 | private cosSideLength(): number { 9 | return COS_60*this.sideLength 10 | } 11 | 12 | private sinSideLength(): number { 13 | return SIN_60*this.sideLength 14 | } 15 | 16 | // adding a new method will cause 'polygon' and 'prism' to recompile 17 | // 18 | // note that in typescript, adding or changing private class members 19 | // has an effect on the declaration, see: 20 | // https://github.com/Microsoft/TypeScript/issues/1867#issuecomment-209018980 21 | 22 | coordinates(): Point2d[] { 23 | const lowerLeft = new Point2d(0, 0) 24 | const left = new Point2d(-1*this.cosSideLength(), this.sinSideLength()) 25 | const upperLeft = new Point2d(0, this.sinSideLength() * 2) 26 | const upperRight = new Point2d(this.sideLength, upperLeft.y) 27 | const right = new Point2d(this.sideLength + -1*left.x, left.y) 28 | const lowerRight = new Point2d(this.sideLength, 0) 29 | 30 | // adding a console.log statment here will only cause 'polygon' to recompile 31 | 32 | return [ 33 | lowerLeft, 34 | left, 35 | upperLeft, 36 | upperRight, 37 | right, 38 | lowerRight, 39 | ] 40 | } 41 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/polygon/polygon.ts: -------------------------------------------------------------------------------- 1 | import {Point2d} from "basics/point2d" 2 | 3 | export interface Polygon { 4 | coordinates(): Point2d[] 5 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/polygon/triangle.ts: -------------------------------------------------------------------------------- 1 | import {Point2d} from "basics/point2d" 2 | import {SIN_60} from "basics/math" 3 | import {Polygon} from "./polygon" 4 | 5 | // changing the name of the function sin60 will only cause 'polygon' to recompile 6 | function sin60(x:number): number { 7 | return SIN_60*x 8 | } 9 | 10 | export class Triangle implements Polygon { 11 | constructor(private sideLength: number) {} 12 | 13 | coordinates(): Point2d[] { 14 | const lowerLeft = new Point2d(0, 0) 15 | const top = new Point2d(sin60(this.sideLength), this.sideLength/2.0) 16 | const lowerRight = new Point2d(this.sideLength, 0) 17 | 18 | return [ 19 | lowerLeft, 20 | top, 21 | lowerRight, 22 | ] 23 | } 24 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/prism/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | # Of note: 6 | # The 'basics' module is not automatically exposed to prism. 7 | # Without the explicit dependency below, Point2d will not 8 | # be seen by tsc, so compilation will fail. 9 | 10 | tsc( 11 | name="tsc", 12 | ts_path="prism", 13 | srcs=glob(["*.ts"]), 14 | deps=[ 15 | "//02_dependent/basics:tsc", 16 | "//02_dependent/polygon:tsc" 17 | ], 18 | 19 | node_executable="@node//:bin/node", 20 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 21 | tsconfig_json="//:tsconfig.json", 22 | ) 23 | -------------------------------------------------------------------------------- /scenarios/02_dependent/prism/hexagonal-prism.ts: -------------------------------------------------------------------------------- 1 | import {Hexagon} from "polygon/hexagon" 2 | import {Point3d} from "./point3d" 3 | 4 | export class HexagonalPrism { 5 | constructor(private sideLength: number, private height: number) {} 6 | 7 | coordinates(): Point3d[] { 8 | const hexagon = new Hexagon(this.sideLength) 9 | 10 | const lowerCoords = hexagon.coordinates().map(p2d => new Point3d(p2d.x, p2d.y, 0)) 11 | const upperCoords = hexagon.coordinates().map(p2d => new Point3d(p2d.x, p2d.y, this.height)) 12 | 13 | return lowerCoords.concat(upperCoords) 14 | } 15 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/prism/point3d.ts: -------------------------------------------------------------------------------- 1 | export class Point3d { 2 | constructor( 3 | public readonly x: number, 4 | public readonly y: number, 5 | public readonly z: number 6 | ){} 7 | } -------------------------------------------------------------------------------- /scenarios/02_dependent/prism/triangular-prism.ts: -------------------------------------------------------------------------------- 1 | import {Triangle} from "polygon/triangle" 2 | import {Point3d} from "./point3d" 3 | 4 | export class TriangularPrism { 5 | constructor(private sideLength: number, private height: number) {} 6 | 7 | coordinates(): Point3d[] { 8 | const triangle = new Triangle(this.sideLength) 9 | 10 | const lowerCoords = triangle.coordinates().map(p2d => new Point3d(p2d.x, p2d.y, 0)) 11 | const upperCoords = triangle.coordinates().map(p2d => new Point3d(p2d.x, p2d.y, this.height)) 12 | 13 | return lowerCoords.concat(upperCoords) 14 | } 15 | } -------------------------------------------------------------------------------- /scenarios/03_single_npm_dep/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_multi_tsc//:def.bzl", "rollup_js_source_bundle") 2 | load("@rules_multi_tsc//:def.bzl", "rollup_js_vendor_bundle") 3 | 4 | rollup_js_vendor_bundle( 5 | name="vendor_bundle", 6 | module_name="vendor", 7 | exports={ 8 | "long": "_long" 9 | }, 10 | deps=[ 11 | "@node_modules_archive//:long" 12 | ], 13 | 14 | node_executable="@node//:bin/node", 15 | rollup_script="@node_modules_archive//:node_modules/rollup/bin/rollup", 16 | rollup_plugins="@node_modules_archive//:rollup_plugins", 17 | ) 18 | 19 | rollup_js_source_bundle( 20 | name="source_bundle", 21 | module_name="source", 22 | entrypoint_js_content="const x = require('lgen/long-gen'); console.log(x.longGen())", 23 | tsc_dep="//03_single_npm_dep/long-gen:tsc", 24 | globals={ 25 | "long": "vendor._long" 26 | }, 27 | 28 | node_executable="@node//:bin/node", 29 | rollup_script="@node_modules_archive//:node_modules/rollup/bin/rollup", 30 | rollup_plugins="@node_modules_archive//:rollup_plugins", 31 | ) 32 | -------------------------------------------------------------------------------- /scenarios/03_single_npm_dep/long-gen/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="lgen", 8 | srcs=glob(["*.ts"]), 9 | deps=[ 10 | "@node_modules_archive//:default_typings", 11 | ], 12 | 13 | node_executable="@node//:bin/node", 14 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 15 | tsconfig_json="//:tsconfig.json", 16 | ) 17 | -------------------------------------------------------------------------------- /scenarios/03_single_npm_dep/long-gen/long-gen.ts: -------------------------------------------------------------------------------- 1 | import * as Long from 'long' 2 | 3 | export function longGen(): Long { 4 | return new Long(77777) 5 | } -------------------------------------------------------------------------------- /scenarios/04_external_deps/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "rollup_js_source_bundle") 4 | load("@rules_multi_tsc//:def.bzl", "rollup_js_vendor_bundle") 5 | load("@rules_multi_tsc//:def.bzl", "uglify_es") 6 | 7 | rollup_js_vendor_bundle( 8 | name="vendor_bundle", 9 | module_name="vendor", 10 | exports={ 11 | "long": "_long", 12 | "bson": "_bson" 13 | }, 14 | deps=[ 15 | "@node_modules_archive//:long", 16 | "@node_modules_archive//:bson", 17 | ], 18 | 19 | node_executable="@node//:bin/node", 20 | rollup_script="@node_modules_archive//:node_modules/rollup/bin/rollup", 21 | rollup_plugins="@node_modules_archive//:rollup_plugins", 22 | ) 23 | 24 | uglify_es( 25 | name="vendor_bundle_min", 26 | node_executable="@node//:bin/node", 27 | uglify_script="@node_modules_archive//:node_modules/uglify-es/bin/uglifyjs", 28 | rollup_dep=":vendor_bundle", 29 | ) 30 | 31 | rollup_js_source_bundle( 32 | name="source_bundle", 33 | module_name="source", 34 | entrypoint_js_content="const x = require('lgen/long-gen'); console.log(x.longGen()); const y = require('ptstamp/print-timestamp'); y.printTimestamp()", 35 | tsc_dep="//04_external_deps/print-timestamp:tsc", 36 | globals={ 37 | "long": "vendor._long", 38 | "bson": "vendor._bson" 39 | }, 40 | 41 | node_executable="@node//:bin/node", 42 | rollup_script="@node_modules_archive//:node_modules/rollup/bin/rollup", 43 | rollup_plugins="@node_modules_archive//:rollup_plugins", 44 | ) 45 | 46 | uglify_es( 47 | name="source_bundle_min", 48 | node_executable="@node//:bin/node", 49 | uglify_script="@node_modules_archive//:node_modules/uglify-es/bin/uglifyjs", 50 | rollup_dep=":source_bundle", 51 | ) 52 | -------------------------------------------------------------------------------- /scenarios/04_external_deps/long-gen/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="lgen", 8 | srcs=glob(["*.ts"]), 9 | deps=[ 10 | "@node_modules_archive//:default_typings", 11 | ], 12 | 13 | node_executable="@node//:bin/node", 14 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 15 | tsconfig_json="//:tsconfig.json", 16 | ) 17 | -------------------------------------------------------------------------------- /scenarios/04_external_deps/long-gen/long-gen.ts: -------------------------------------------------------------------------------- 1 | import * as Long from "long" 2 | 3 | export function longGen(): Long { 4 | return new Long(77777) 5 | } -------------------------------------------------------------------------------- /scenarios/04_external_deps/print-timestamp/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="ptstamp", 8 | srcs=glob(["*.ts"]), 9 | deps=[ 10 | "@node_modules_archive//:default_typings", 11 | "//04_external_deps/long-gen:tsc", 12 | ], 13 | 14 | node_executable="@node//:bin/node", 15 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 16 | tsconfig_json="//:tsconfig.json", 17 | ) 18 | -------------------------------------------------------------------------------- /scenarios/04_external_deps/print-timestamp/print-timestamp.ts: -------------------------------------------------------------------------------- 1 | import { longGen } from "lgen/long-gen" 2 | import { Timestamp } from "bson" 3 | 4 | export function printTimestamp() { 5 | const l = longGen() 6 | const t = Timestamp.fromBits(l.low, l.high) 7 | console.log(t) 8 | } 9 | -------------------------------------------------------------------------------- /scenarios/05_compile_ts_out/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | load("@rules_multi_tsc//:def.bzl", "rollup_js_source_bundle") 5 | 6 | genrule( 7 | name = "gen_ts", 8 | srcs = [], 9 | outs = ["foo.ts"], 10 | cmd = "echo 'export function doprint(): void { console.log(\"hello foo\") }' > \"$@\"", 11 | ) 12 | 13 | tsc( 14 | name="tsc", 15 | ts_path="compiletsout", 16 | srcs=[":gen_ts"], 17 | 18 | node_executable="@node//:bin/node", 19 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 20 | tsconfig_json="//:tsconfig.json", 21 | ) 22 | 23 | rollup_js_source_bundle( 24 | name="bundle", 25 | entrypoint_js_content="const x = require('compiletsout/foo'); x.doprint()", 26 | module_name="someModule", 27 | tsc_dep=":tsc", 28 | 29 | node_executable="@node//:bin/node", 30 | rollup_script="@node_modules_archive//:node_modules/rollup/bin/rollup", 31 | rollup_plugins="@node_modules_archive//:rollup_plugins", 32 | ) 33 | -------------------------------------------------------------------------------- /scenarios/06_typings/ts_src/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "tsc") 4 | 5 | tsc( 6 | name="tsc", 7 | ts_path="shape", 8 | srcs=["square.ts"], 9 | deps=[ 10 | "//06_typings/typings:typings", 11 | ], 12 | 13 | node_executable="@node//:bin/node", 14 | tsc_script="@node_modules_archive//:node_modules/typescript/lib/tsc.js", 15 | tsconfig_json="//:tsconfig.json", 16 | ) 17 | -------------------------------------------------------------------------------- /scenarios/06_typings/ts_src/square.ts: -------------------------------------------------------------------------------- 1 | import {Shape} from "shape-typings/shape" 2 | 3 | class Square implements Shape { 4 | constructor(private sideLength: number) {} 5 | 6 | sides(): number[] { 7 | return [this.sideLength, this.sideLength, this.sideLength, this.sideLength] 8 | } 9 | } -------------------------------------------------------------------------------- /scenarios/06_typings/typings/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | load("@rules_multi_tsc//:def.bzl", "typings") 4 | 5 | typings( 6 | name="typings", 7 | ts_path="shape-typings", 8 | srcs=["shape.d.ts"], 9 | ) 10 | -------------------------------------------------------------------------------- /scenarios/06_typings/typings/shape.d.ts: -------------------------------------------------------------------------------- 1 | export interface Shape { 2 | sides(): number[] 3 | } -------------------------------------------------------------------------------- /scenarios/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//:__subpackages__"]) 2 | 3 | exports_files(["tsconfig.json"]) -------------------------------------------------------------------------------- /scenarios/WORKSPACE: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | 3 | local_repository( 4 | name = "rules_multi_tsc", 5 | path = "../rules", 6 | ) 7 | 8 | new_local_repository( 9 | name="node_modules_archive", 10 | path=".", 11 | build_file_content=""" 12 | exports_files([ 13 | "node_modules/typescript/lib/tsc.js", 14 | "node_modules/rollup/bin/rollup", 15 | "node_modules/uglify-es/bin/uglifyjs", 16 | ]) 17 | 18 | filegroup( 19 | name = "default_typings", 20 | srcs = glob([ 21 | "node_modules/@types/**", 22 | ]), 23 | visibility = ["//visibility:public"], 24 | ) 25 | 26 | filegroup(name = "long", srcs = glob(["node_modules/long/**/*",]), visibility = ["//visibility:public"]) 27 | filegroup(name = "bson", srcs = glob(["node_modules/bson/**/*",]), visibility = ["//visibility:public"]) 28 | filegroup(name = "buffer", srcs = glob(["node_modules/buffer/**/*",]), visibility = ["//visibility:public"]) 29 | 30 | filegroup( 31 | name = "rollup_plugins", 32 | srcs = glob([ 33 | "node_modules/rollup-plugin-commonjs/**/*", 34 | "node_modules/rollup-plugin-node-resolve/**/*", 35 | "node_modules/rollup-plugin-alias/**/*", 36 | "node_modules/rollup-plugin-includepaths/**/*", 37 | "node_modules/rollup-plugin-replace/**/*", 38 | ]), 39 | visibility = ["//visibility:public"], 40 | ) 41 | """ 42 | ) 43 | 44 | http_archive( 45 | name = "node", 46 | url = "https://nodejs.org/dist/v10.14.2/node-v10.14.2-darwin-x64.tar.gz", 47 | strip_prefix = "node-v10.14.2-darwin-x64", 48 | build_file_content=""" 49 | exports_files([ 50 | "bin/node", 51 | ]) 52 | """ 53 | ) 54 | -------------------------------------------------------------------------------- /scenarios/index01.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /scenarios/index02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /scenarios/index03.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /scenarios/index04-min.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /scenarios/index04.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /scenarios/index05.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /scenarios/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-app", 3 | "version": "0.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/bson": { 8 | "version": "1.0.11", 9 | "resolved": "https://registry.npmjs.org/@types/bson/-/bson-1.0.11.tgz", 10 | "integrity": "sha512-j+UcCWI+FsbI5/FQP/Kj2CXyplWAz39ktHFkXk84h7dNblKRSoNJs95PZFRd96NQGqsPEPgeclqnznWZr14ZDA==", 11 | "dev": true, 12 | "requires": { 13 | "@types/node": "*" 14 | } 15 | }, 16 | "@types/estree": { 17 | "version": "0.0.39", 18 | "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", 19 | "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", 20 | "dev": true 21 | }, 22 | "@types/long": { 23 | "version": "4.0.0", 24 | "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz", 25 | "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==", 26 | "dev": true 27 | }, 28 | "@types/node": { 29 | "version": "10.12.18", 30 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", 31 | "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", 32 | "dev": true 33 | }, 34 | "arr-diff": { 35 | "version": "2.0.0", 36 | "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", 37 | "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", 38 | "dev": true, 39 | "requires": { 40 | "arr-flatten": "^1.0.1" 41 | } 42 | }, 43 | "arr-flatten": { 44 | "version": "1.1.0", 45 | "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", 46 | "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", 47 | "dev": true 48 | }, 49 | "array-unique": { 50 | "version": "0.2.1", 51 | "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", 52 | "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", 53 | "dev": true 54 | }, 55 | "atob": { 56 | "version": "2.1.2", 57 | "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", 58 | "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", 59 | "dev": true 60 | }, 61 | "balanced-match": { 62 | "version": "1.0.0", 63 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 64 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 65 | "dev": true 66 | }, 67 | "base64-js": { 68 | "version": "1.3.0", 69 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", 70 | "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" 71 | }, 72 | "brace-expansion": { 73 | "version": "1.1.11", 74 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 75 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 76 | "dev": true, 77 | "requires": { 78 | "balanced-match": "^1.0.0", 79 | "concat-map": "0.0.1" 80 | } 81 | }, 82 | "braces": { 83 | "version": "1.8.5", 84 | "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", 85 | "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", 86 | "dev": true, 87 | "requires": { 88 | "expand-range": "^1.8.1", 89 | "preserve": "^0.2.0", 90 | "repeat-element": "^1.1.2" 91 | } 92 | }, 93 | "bson": { 94 | "version": "4.0.1", 95 | "resolved": "https://registry.npmjs.org/bson/-/bson-4.0.1.tgz", 96 | "integrity": "sha512-Q+E5edAc2DnSb77xcBJga0iJDyZlhkKRhWxKdPJcT3UK6nC6BtmMJGpkt+99bGht3HIhXHu7mxi5FLBgQAj5MA==", 97 | "requires": { 98 | "buffer": "^5.1.0", 99 | "long": "^4.0.0" 100 | } 101 | }, 102 | "buffer": { 103 | "version": "5.2.1", 104 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", 105 | "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", 106 | "requires": { 107 | "base64-js": "^1.0.2", 108 | "ieee754": "^1.1.4" 109 | } 110 | }, 111 | "builtin-modules": { 112 | "version": "2.0.0", 113 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-2.0.0.tgz", 114 | "integrity": "sha512-3U5kUA5VPsRUA3nofm/BXX7GVHKfxz0hOBAPxXrIvHzlDRkQVqEn6yi8QJegxl4LzOHLdvb7XF5dVawa/VVYBg==", 115 | "dev": true 116 | }, 117 | "commander": { 118 | "version": "2.13.0", 119 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", 120 | "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", 121 | "dev": true 122 | }, 123 | "concat-map": { 124 | "version": "0.0.1", 125 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 126 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 127 | "dev": true 128 | }, 129 | "decode-uri-component": { 130 | "version": "0.2.0", 131 | "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", 132 | "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", 133 | "dev": true 134 | }, 135 | "estree-walker": { 136 | "version": "0.5.2", 137 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", 138 | "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==", 139 | "dev": true 140 | }, 141 | "expand-brackets": { 142 | "version": "0.1.5", 143 | "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", 144 | "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", 145 | "dev": true, 146 | "requires": { 147 | "is-posix-bracket": "^0.1.0" 148 | } 149 | }, 150 | "expand-range": { 151 | "version": "1.8.2", 152 | "resolved": "http://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", 153 | "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", 154 | "dev": true, 155 | "requires": { 156 | "fill-range": "^2.1.0" 157 | } 158 | }, 159 | "extglob": { 160 | "version": "0.3.2", 161 | "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", 162 | "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", 163 | "dev": true, 164 | "requires": { 165 | "is-extglob": "^1.0.0" 166 | } 167 | }, 168 | "filename-regex": { 169 | "version": "2.0.1", 170 | "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", 171 | "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", 172 | "dev": true 173 | }, 174 | "fill-range": { 175 | "version": "2.2.4", 176 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", 177 | "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", 178 | "dev": true, 179 | "requires": { 180 | "is-number": "^2.1.0", 181 | "isobject": "^2.0.0", 182 | "randomatic": "^3.0.0", 183 | "repeat-element": "^1.1.2", 184 | "repeat-string": "^1.5.2" 185 | } 186 | }, 187 | "for-in": { 188 | "version": "1.0.2", 189 | "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", 190 | "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", 191 | "dev": true 192 | }, 193 | "for-own": { 194 | "version": "0.1.5", 195 | "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", 196 | "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", 197 | "dev": true, 198 | "requires": { 199 | "for-in": "^1.0.1" 200 | } 201 | }, 202 | "glob-base": { 203 | "version": "0.3.0", 204 | "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", 205 | "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", 206 | "dev": true, 207 | "requires": { 208 | "glob-parent": "^2.0.0", 209 | "is-glob": "^2.0.0" 210 | } 211 | }, 212 | "glob-parent": { 213 | "version": "2.0.0", 214 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", 215 | "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", 216 | "dev": true, 217 | "requires": { 218 | "is-glob": "^2.0.0" 219 | } 220 | }, 221 | "ieee754": { 222 | "version": "1.1.12", 223 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", 224 | "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==" 225 | }, 226 | "is-buffer": { 227 | "version": "1.1.6", 228 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", 229 | "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", 230 | "dev": true 231 | }, 232 | "is-dotfile": { 233 | "version": "1.0.3", 234 | "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", 235 | "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", 236 | "dev": true 237 | }, 238 | "is-equal-shallow": { 239 | "version": "0.1.3", 240 | "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", 241 | "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", 242 | "dev": true, 243 | "requires": { 244 | "is-primitive": "^2.0.0" 245 | } 246 | }, 247 | "is-extendable": { 248 | "version": "0.1.1", 249 | "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", 250 | "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", 251 | "dev": true 252 | }, 253 | "is-extglob": { 254 | "version": "1.0.0", 255 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", 256 | "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", 257 | "dev": true 258 | }, 259 | "is-glob": { 260 | "version": "2.0.1", 261 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", 262 | "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", 263 | "dev": true, 264 | "requires": { 265 | "is-extglob": "^1.0.0" 266 | } 267 | }, 268 | "is-module": { 269 | "version": "1.0.0", 270 | "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", 271 | "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", 272 | "dev": true 273 | }, 274 | "is-number": { 275 | "version": "2.1.0", 276 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", 277 | "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", 278 | "dev": true, 279 | "requires": { 280 | "kind-of": "^3.0.2" 281 | } 282 | }, 283 | "is-posix-bracket": { 284 | "version": "0.1.1", 285 | "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", 286 | "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", 287 | "dev": true 288 | }, 289 | "is-primitive": { 290 | "version": "2.0.0", 291 | "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", 292 | "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", 293 | "dev": true 294 | }, 295 | "isarray": { 296 | "version": "1.0.0", 297 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 298 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", 299 | "dev": true 300 | }, 301 | "isobject": { 302 | "version": "2.1.0", 303 | "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", 304 | "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", 305 | "dev": true, 306 | "requires": { 307 | "isarray": "1.0.0" 308 | } 309 | }, 310 | "kind-of": { 311 | "version": "3.2.2", 312 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", 313 | "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", 314 | "dev": true, 315 | "requires": { 316 | "is-buffer": "^1.1.5" 317 | } 318 | }, 319 | "long": { 320 | "version": "4.0.0", 321 | "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", 322 | "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" 323 | }, 324 | "magic-string": { 325 | "version": "0.25.1", 326 | "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.1.tgz", 327 | "integrity": "sha512-sCuTz6pYom8Rlt4ISPFn6wuFodbKMIHUMv4Qko9P17dpxb7s52KJTmRuZZqHdGmLCK9AOcDare039nRIcfdkEg==", 328 | "dev": true, 329 | "requires": { 330 | "sourcemap-codec": "^1.4.1" 331 | } 332 | }, 333 | "math-random": { 334 | "version": "1.0.1", 335 | "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", 336 | "integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=", 337 | "dev": true 338 | }, 339 | "micromatch": { 340 | "version": "2.3.11", 341 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", 342 | "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", 343 | "dev": true, 344 | "requires": { 345 | "arr-diff": "^2.0.0", 346 | "array-unique": "^0.2.1", 347 | "braces": "^1.8.2", 348 | "expand-brackets": "^0.1.4", 349 | "extglob": "^0.3.1", 350 | "filename-regex": "^2.0.0", 351 | "is-extglob": "^1.0.0", 352 | "is-glob": "^2.0.1", 353 | "kind-of": "^3.0.2", 354 | "normalize-path": "^2.0.1", 355 | "object.omit": "^2.0.0", 356 | "parse-glob": "^3.0.4", 357 | "regex-cache": "^0.4.2" 358 | } 359 | }, 360 | "minimatch": { 361 | "version": "3.0.4", 362 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 363 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 364 | "dev": true, 365 | "requires": { 366 | "brace-expansion": "^1.1.7" 367 | } 368 | }, 369 | "normalize-path": { 370 | "version": "2.1.1", 371 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", 372 | "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", 373 | "dev": true, 374 | "requires": { 375 | "remove-trailing-separator": "^1.0.1" 376 | } 377 | }, 378 | "object.omit": { 379 | "version": "2.0.1", 380 | "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", 381 | "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", 382 | "dev": true, 383 | "requires": { 384 | "for-own": "^0.1.4", 385 | "is-extendable": "^0.1.1" 386 | } 387 | }, 388 | "parse-glob": { 389 | "version": "3.0.4", 390 | "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", 391 | "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", 392 | "dev": true, 393 | "requires": { 394 | "glob-base": "^0.3.0", 395 | "is-dotfile": "^1.0.0", 396 | "is-extglob": "^1.0.0", 397 | "is-glob": "^2.0.0" 398 | } 399 | }, 400 | "path-parse": { 401 | "version": "1.0.6", 402 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 403 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", 404 | "dev": true 405 | }, 406 | "preserve": { 407 | "version": "0.2.0", 408 | "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", 409 | "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", 410 | "dev": true 411 | }, 412 | "randomatic": { 413 | "version": "3.1.1", 414 | "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", 415 | "integrity": "sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==", 416 | "dev": true, 417 | "requires": { 418 | "is-number": "^4.0.0", 419 | "kind-of": "^6.0.0", 420 | "math-random": "^1.0.1" 421 | }, 422 | "dependencies": { 423 | "is-number": { 424 | "version": "4.0.0", 425 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", 426 | "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", 427 | "dev": true 428 | }, 429 | "kind-of": { 430 | "version": "6.0.2", 431 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", 432 | "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", 433 | "dev": true 434 | } 435 | } 436 | }, 437 | "regex-cache": { 438 | "version": "0.4.4", 439 | "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", 440 | "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", 441 | "dev": true, 442 | "requires": { 443 | "is-equal-shallow": "^0.1.3" 444 | } 445 | }, 446 | "remove-trailing-separator": { 447 | "version": "1.1.0", 448 | "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", 449 | "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", 450 | "dev": true 451 | }, 452 | "repeat-element": { 453 | "version": "1.1.3", 454 | "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", 455 | "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", 456 | "dev": true 457 | }, 458 | "repeat-string": { 459 | "version": "1.6.1", 460 | "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", 461 | "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", 462 | "dev": true 463 | }, 464 | "resolve": { 465 | "version": "1.9.0", 466 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.9.0.tgz", 467 | "integrity": "sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ==", 468 | "dev": true, 469 | "requires": { 470 | "path-parse": "^1.0.6" 471 | } 472 | }, 473 | "resolve-url": { 474 | "version": "0.2.1", 475 | "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", 476 | "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", 477 | "dev": true 478 | }, 479 | "rollup": { 480 | "version": "0.67.4", 481 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.67.4.tgz", 482 | "integrity": "sha512-AVuP73mkb4BBMUmksQ3Jw0jTrBTU1i7rLiUYjFxLZGb3xiFmtVEg40oByphkZAsiL0bJC3hRAJUQos/e5EBd+w==", 483 | "dev": true, 484 | "requires": { 485 | "@types/estree": "0.0.39", 486 | "@types/node": "*" 487 | } 488 | }, 489 | "rollup-plugin-alias": { 490 | "version": "1.5.1", 491 | "resolved": "https://registry.npmjs.org/rollup-plugin-alias/-/rollup-plugin-alias-1.5.1.tgz", 492 | "integrity": "sha512-pQTYBRNfLedoVOO7AYHNegIavEIp4jKTga5jUi1r//KYgHKGWgG4qJXYhbcWKt2k1FwGlR5wCYoY+IFkme0t4A==", 493 | "dev": true, 494 | "requires": { 495 | "slash": "^2.0.0" 496 | } 497 | }, 498 | "rollup-plugin-commonjs": { 499 | "version": "9.2.0", 500 | "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.0.tgz", 501 | "integrity": "sha512-0RM5U4Vd6iHjL6rLvr3lKBwnPsaVml+qxOGaaNUWN1lSq6S33KhITOfHmvxV3z2vy9Mk4t0g4rNlVaJJsNQPWA==", 502 | "dev": true, 503 | "requires": { 504 | "estree-walker": "^0.5.2", 505 | "magic-string": "^0.25.1", 506 | "resolve": "^1.8.1", 507 | "rollup-pluginutils": "^2.3.3" 508 | } 509 | }, 510 | "rollup-plugin-includepaths": { 511 | "version": "0.2.3", 512 | "resolved": "https://registry.npmjs.org/rollup-plugin-includepaths/-/rollup-plugin-includepaths-0.2.3.tgz", 513 | "integrity": "sha512-4QbSIZPDT+FL4SViEVCRi4cGCA64zQJu7u5qmCkO3ecHy+l9EQBsue15KfCpddfb6Br0q47V/v2+E2YUiqts9g==", 514 | "dev": true 515 | }, 516 | "rollup-plugin-node-resolve": { 517 | "version": "3.4.0", 518 | "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.4.0.tgz", 519 | "integrity": "sha512-PJcd85dxfSBWih84ozRtBkB731OjXk0KnzN0oGp7WOWcarAFkVa71cV5hTJg2qpVsV2U8EUwrzHP3tvy9vS3qg==", 520 | "dev": true, 521 | "requires": { 522 | "builtin-modules": "^2.0.0", 523 | "is-module": "^1.0.0", 524 | "resolve": "^1.1.6" 525 | } 526 | }, 527 | "rollup-plugin-replace": { 528 | "version": "2.1.0", 529 | "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.1.0.tgz", 530 | "integrity": "sha512-SxrAIgpH/B5/W4SeULgreOemxcpEgKs2gcD42zXw50bhqGWmcnlXneVInQpAqzA/cIly4bJrOpeelmB9p4YXSQ==", 531 | "dev": true, 532 | "requires": { 533 | "magic-string": "^0.25.1", 534 | "minimatch": "^3.0.2", 535 | "rollup-pluginutils": "^2.0.1" 536 | } 537 | }, 538 | "rollup-plugin-sourcemaps": { 539 | "version": "0.4.2", 540 | "resolved": "https://registry.npmjs.org/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.4.2.tgz", 541 | "integrity": "sha1-YhJaqUCHqt97g+9N+vYptHMTXoc=", 542 | "dev": true, 543 | "requires": { 544 | "rollup-pluginutils": "^2.0.1", 545 | "source-map-resolve": "^0.5.0" 546 | } 547 | }, 548 | "rollup-pluginutils": { 549 | "version": "2.3.3", 550 | "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz", 551 | "integrity": "sha512-2XZwja7b6P5q4RZ5FhyX1+f46xi1Z3qBKigLRZ6VTZjwbN0K1IFGMlwm06Uu0Emcre2Z63l77nq/pzn+KxIEoA==", 552 | "dev": true, 553 | "requires": { 554 | "estree-walker": "^0.5.2", 555 | "micromatch": "^2.3.11" 556 | } 557 | }, 558 | "slash": { 559 | "version": "2.0.0", 560 | "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", 561 | "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", 562 | "dev": true 563 | }, 564 | "source-map": { 565 | "version": "0.6.1", 566 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 567 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 568 | "dev": true 569 | }, 570 | "source-map-resolve": { 571 | "version": "0.5.2", 572 | "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", 573 | "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", 574 | "dev": true, 575 | "requires": { 576 | "atob": "^2.1.1", 577 | "decode-uri-component": "^0.2.0", 578 | "resolve-url": "^0.2.1", 579 | "source-map-url": "^0.4.0", 580 | "urix": "^0.1.0" 581 | } 582 | }, 583 | "source-map-url": { 584 | "version": "0.4.0", 585 | "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", 586 | "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", 587 | "dev": true 588 | }, 589 | "sourcemap-codec": { 590 | "version": "1.4.4", 591 | "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz", 592 | "integrity": "sha512-CYAPYdBu34781kLHkaW3m6b/uUSyMOC2R61gcYMWooeuaGtjof86ZA/8T+qVPPt7np1085CR9hmMGrySwEc8Xg==", 593 | "dev": true 594 | }, 595 | "typescript": { 596 | "version": "3.1.6", 597 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz", 598 | "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==", 599 | "dev": true 600 | }, 601 | "uglify-es": { 602 | "version": "3.3.9", 603 | "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", 604 | "integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==", 605 | "dev": true, 606 | "requires": { 607 | "commander": "~2.13.0", 608 | "source-map": "~0.6.1" 609 | } 610 | }, 611 | "urix": { 612 | "version": "0.1.0", 613 | "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", 614 | "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", 615 | "dev": true 616 | } 617 | } 618 | } 619 | -------------------------------------------------------------------------------- /scenarios/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-app", 3 | "version": "0.0.0", 4 | "scripts": {}, 5 | "private": true, 6 | "dependencies": { 7 | "long": "4.0.0", 8 | "bson": "4.0.1", 9 | "buffer": "5.2.1" 10 | }, 11 | "devDependencies": { 12 | "@types/long": "4.0.0", 13 | "@types/bson": "1.0.11", 14 | "typescript": "~3.1.6", 15 | "rollup": "0.67.4", 16 | "rollup-plugin-alias": "1.5.1", 17 | "rollup-plugin-node-resolve": "3.4.0", 18 | "rollup-plugin-commonjs": "9.2.0", 19 | "rollup-plugin-includepaths": "0.2.3", 20 | "rollup-plugin-sourcemaps": "0.4.2", 21 | "rollup-plugin-replace": "2.1.0", 22 | "uglify-es": "3.3.9" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /scenarios/rollupjs_experiment/bar.js: -------------------------------------------------------------------------------- 1 | const Long = require('long') 2 | 3 | const l = new Long(8888) 4 | console.log(l) 5 | 6 | const Bson = require('bson') 7 | console.log(Bson.serialize({a: Long.fromNumber(100)})) -------------------------------------------------------------------------------- /scenarios/rollupjs_experiment/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Hi 8 | 9 | 10 | -------------------------------------------------------------------------------- /scenarios/rollupjs_experiment/rollup-source.js: -------------------------------------------------------------------------------- 1 | import resolve from 'rollup-plugin-node-resolve' 2 | import commonjs from 'rollup-plugin-commonjs' 3 | 4 | export default { 5 | input: 'bar.js', 6 | output: { 7 | dir: "dist", 8 | format: 'iife', 9 | name: 'source', 10 | sourcemap: true, 11 | file: "dist/source.js", 12 | globals: { 13 | 'long': 'vendor._long', 14 | 'bson': 'vendor._bson' 15 | } 16 | }, 17 | external: ['bson', 'long'], 18 | plugins: [ 19 | resolve({ 20 | preferBuiltins: false 21 | }), 22 | commonjs() 23 | ] 24 | } -------------------------------------------------------------------------------- /scenarios/rollupjs_experiment/rollup-vendor.js: -------------------------------------------------------------------------------- 1 | import resolve from 'rollup-plugin-node-resolve' 2 | import commonjs from 'rollup-plugin-commonjs' 3 | 4 | export default { 5 | input: 'vendor.js', 6 | output: { 7 | dir: "dist", 8 | format: 'iife', 9 | sourcemap: true, 10 | name: "vendor", 11 | file: "dist/vendor.js", 12 | intro: 'window.global = window' 13 | }, 14 | plugins: [ 15 | resolve({ 16 | preferBuiltins: false 17 | }), 18 | commonjs() 19 | ] 20 | } -------------------------------------------------------------------------------- /scenarios/rollupjs_experiment/vendor.js: -------------------------------------------------------------------------------- 1 | import * as _long from 'long' 2 | import * as _bson from 'bson' 3 | 4 | export default { 5 | _long, 6 | _bson 7 | } -------------------------------------------------------------------------------- /scenarios/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "lib": ["es2015", "dom"], 9 | "noImplicitAny": true, 10 | "suppressImplicitAnyIndexErrors": true, 11 | "outDir": "../whatever", 12 | "baseUrl": ".", 13 | "skipDefaultLibCheck": true, 14 | "allowSyntheticDefaultImports": true 15 | } 16 | } --------------------------------------------------------------------------------