Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make paths relative rather than absolute in the Es6RewriteImportPaths…
… pass. Just resolving import paths doesn't work for all servers. If a client transpiles the paths will be rooted (starting with "/") but the path of the file could be considered to be absolute (with a scheme). So you'll end up with something like: $jscomp.registerAndLoadModule(function($$require) { }, "http://localhost:port/file.js", []); $jscomp.registerAndLoadModule(function($$require) { $$require('/file.js'); }, "http://localhost:port/path.js", ['/file.js']); Which won't ever be resolved as the jscomp module runtime's path resolution is very simple. Making these paths relative will resolve them correctly as the runtime can handle those (so in the above exampled '/file.js' becomes './file.js'). Ideally servers would just transpile the ES6 module themselves to avoid client transpilation, but this isn't always possible. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202347411
- Loading branch information
Showing
6 changed files
with
173 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...le/javascript/jscomp/gwt/super/com/google/javascript/jscomp/Es6RelativizeImportPaths.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
/* | |||
* Copyright 2018 The Closure Compiler Authors. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package com.google.javascript.jscomp; | |||
|
|||
import com.google.javascript.rhino.Node; | |||
|
|||
/** GWT compatible no-op replacement for {@code Es6RelativizeImportPaths} */ | |||
class Es6RelativizeImportPaths implements CompilerPass { | |||
Es6RelativizeImportPaths(AbstractCompiler compiler) { | |||
} | |||
|
|||
@Override | |||
public void process(Node externs, Node root) { | |||
throw new UnsupportedOperationException("Es6RelativizeImportPaths not implemented"); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters