diff options
author | Solly Ross <sross@redhat.com> | 2017-10-03 18:40:52 -0400 |
---|---|---|
committer | Solly Ross <sross@redhat.com> | 2017-10-03 19:30:20 -0400 |
commit | a80955ee7a7479acf3a6c9ec2221bfba22a1d934 (patch) | |
tree | 635b7972125bf62246c445c53c8117b2b98d9d15 | |
parent | c4e5a50e09fe44f17c3ac7f81a36b2a9146c3b21 (diff) | |
download | novnc-a80955ee7a7479acf3a6c9ec2221bfba22a1d934.tar.gz |
[infra] fix vendor import paths on built files
A previous commit started (quasi-correctly) rewriting vendor import
paths on built files. The gist of it was correct, but it incorrectly
rewrote paths in vendor itself.
The babel plugin in use operated on canonical absolute paths. This mean
that it saw no difference between the import
`../vendor/pako/lib/utils/foo` and `../utils/foo`, where the later was
actually in the `vendor/pako/lib/bar` directory. This rewrote imports
in files in the vendor directory itself. However, since those files
were *already* in the correct relative location, the new import was
incorrect by a degree of `..`.
Now, we only rewrite vendor paths on things in the `core` directory.
-rwxr-xr-x | utils/use_require.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/utils/use_require.js b/utils/use_require.js index fea1b1d..050efa2 100755 --- a/utils/use_require.js +++ b/utils/use_require.js @@ -108,8 +108,8 @@ var make_lib_files = function (import_format, source_maps, with_app_dir) { const helpers = require('./use_require_helpers'); const helper = helpers[import_format]; - - var handleDir = (js_only, in_path_base, filename) => { + + var handleDir = (js_only, vendor_rewrite, in_path_base, filename) => { if (no_copy_files.has(filename)) return; const out_path = path.join(out_path_base, path.relative(in_path_base, filename)); @@ -134,7 +134,7 @@ var make_lib_files = function (import_format, source_maps, with_app_dir) { } // Adjust for the fact that we move the core files relative // to the vendor directory - if (!in_path) { + if (vendor_rewrite) { opts.plugins.push(["import-redirect", {"root": out_path_base, "redirect": { "vendor/(.+)": "./vendor/$1"}}]); @@ -161,11 +161,11 @@ var make_lib_files = function (import_format, source_maps, with_app_dir) { helper.noCopyOverride(paths, no_copy_files); } - walkDir(paths.core, handleDir.bind(null, true, in_path || paths.core), (filename, stats) => !no_copy_files.has(filename)); - walkDir(paths.vendor, handleDir.bind(null, true, in_path || paths.main), (filename, stats) => !no_copy_files.has(filename)); + walkDir(paths.vendor, handleDir.bind(null, true, false, in_path || paths.main), (filename, stats) => !no_copy_files.has(filename)); + walkDir(paths.core, handleDir.bind(null, true, !in_path, in_path || paths.core), (filename, stats) => !no_copy_files.has(filename)); if (with_app_dir) { - walkDir(paths.app, handleDir.bind(null, false, in_path || paths.app), (filename, stats) => !no_copy_files.has(filename)); + walkDir(paths.app, handleDir.bind(null, false, false, in_path), (filename, stats) => !no_copy_files.has(filename)); const out_app_path = path.join(out_path_base, 'app.js'); if (helper && helper.appWriter) { |