Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/module_builder.dart

Issue 2860943003: update dependencies to use url style paths (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:args/args.dart' show ArgParser, ArgResults; 5 import 'package:args/args.dart' show ArgParser, ArgResults;
6 import 'package:path/path.dart' as path; 6 import 'package:path/path.dart' as path;
7 7
8 import '../js_ast/js_ast.dart'; 8 import '../js_ast/js_ast.dart';
9 import 'js_names.dart'; 9 import 'js_names.dart';
10 10
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Collect imports/exports/statements. 267 // Collect imports/exports/statements.
268 visitProgram(module); 268 visitProgram(module);
269 269
270 var dependencies = <LiteralString>[]; 270 var dependencies = <LiteralString>[];
271 var fnParams = <Parameter>[]; 271 var fnParams = <Parameter>[];
272 for (var import in imports) { 272 for (var import in imports) {
273 // TODO(jmesserly): we could use destructuring once Atom supports it. 273 // TODO(jmesserly): we could use destructuring once Atom supports it.
274 var moduleVar = 274 var moduleVar =
275 new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes)); 275 new TemporaryId(pathToJSIdentifier(import.from.valueWithoutQuotes));
276 fnParams.add(moduleVar); 276 fnParams.add(moduleVar);
277 dependencies.add(import.from); 277 dependencies.add(new LiteralString(
278 '"${path.url.joinAll(path.split(import.from.valueWithoutQuotes))}"'));
Jennifer Messerly 2017/05/04 18:20:26 we chatted about moving this fix to code_generator
278 279
279 // TODO(jmesserly): optimize for the common case of a single import. 280 // TODO(jmesserly): optimize for the common case of a single import.
280 for (var importName in import.namedImports) { 281 for (var importName in import.namedImports) {
281 // import * is not emitted by the compiler, so we don't handle it here. 282 // import * is not emitted by the compiler, so we don't handle it here.
282 assert(!importName.isStar); 283 assert(!importName.isStar);
283 var asName = importName.asName ?? importName.name; 284 var asName = importName.asName ?? importName.name;
284 importStatements.add(js.statement( 285 importStatements.add(js.statement(
285 'const # = #.#', [asName, moduleVar, importName.name.name])); 286 'const # = #.#', [asName, moduleVar, importName.name.name]));
286 } 287 }
287 } 288 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // Ensure the identifier first character is not numeric and that the whole 345 // Ensure the identifier first character is not numeric and that the whole
345 // identifier is not a keyword. 346 // identifier is not a keyword.
346 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) { 347 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) {
347 return '\$$result'; 348 return '\$$result';
348 } 349 }
349 return result; 350 return result;
350 } 351 }
351 352
352 // Invalid characters for identifiers, which would need to be escaped. 353 // Invalid characters for identifiers, which would need to be escaped.
353 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]'); 354 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]');
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698