mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor: update compiler-cli to work with ESM (#48521)
Updates compiler-cli & tests to be full ESM compatible. Tests no longer with CommonJS. PR Close #48521
This commit is contained in:
@@ -5,9 +5,10 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import babel, {PluginObj} from '@babel/core';
|
||||
|
||||
import {needsLinking} from '../../../linker';
|
||||
import {createEs2015LinkerPlugin} from '../../../linker/babel';
|
||||
import {PluginObj, transformSync} from '../../../linker/babel/src/babel_core';
|
||||
import {AbsoluteFsPath, FileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {ConsoleLogger, LogLevel} from '../../../src/ngtsc/logging';
|
||||
import {MapAndPath, RawSourceMap, SourceFileLoader} from '../../../src/ngtsc/sourcemaps';
|
||||
@@ -88,7 +89,7 @@ function applyLinker(
|
||||
if (!filename.endsWith('.js') || !needsLinking(filename, source)) {
|
||||
return {linkedSource: source, linkedSourceMap: sourceMap};
|
||||
}
|
||||
const result = transformSync(source, {
|
||||
const result = babel.transformSync(source, {
|
||||
cwd,
|
||||
filename,
|
||||
sourceMaps: !!sourceMap,
|
||||
|
||||
@@ -17,7 +17,8 @@ def partial_compliance_golden(filePath):
|
||||
nodejs_binary(
|
||||
name = generate_partial_name,
|
||||
testonly = True,
|
||||
data = data + [filePath],
|
||||
data = data,
|
||||
data_for_args = [filePath],
|
||||
visibility = [":__pkg__"],
|
||||
entry_point = "//packages/compiler-cli/test/compliance/partial:cli.ts",
|
||||
templated_args = ["$(execpath %s)" % filePath],
|
||||
|
||||
@@ -12,7 +12,7 @@ import ts from 'typescript';
|
||||
|
||||
import * as ng from '../index';
|
||||
import {NodeJSFileSystem, setFileSystem} from '../src/ngtsc/file_system';
|
||||
import {getAngularPackagesFromRunfiles, resolveNpmTreeArtifact} from '../src/ngtsc/testing';
|
||||
import {getAngularPackagesFromRunfiles, resolveFromRunfiles} from '../src/ngtsc/testing';
|
||||
|
||||
// TEST_TMPDIR is always set by Bazel.
|
||||
const tmpdir = process.env.TEST_TMPDIR!;
|
||||
@@ -132,14 +132,14 @@ export function setupBazelTo(tmpDirPath: string) {
|
||||
});
|
||||
|
||||
// Link typescript
|
||||
const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript');
|
||||
const typeScriptSource = resolveFromRunfiles('npm/node_modules/typescript');
|
||||
const typescriptDest = path.join(nodeModulesPath, 'typescript');
|
||||
fs.symlinkSync(typeScriptSource, typescriptDest, 'junction');
|
||||
|
||||
// Link "rxjs" if it has been set up as a runfile. "rxjs" is linked optionally because
|
||||
// not all compiler-cli tests need "rxjs" set up.
|
||||
try {
|
||||
const rxjsSource = resolveNpmTreeArtifact('rxjs', 'index.js');
|
||||
const rxjsSource = resolveFromRunfiles('npm/node_modules/rxjs');
|
||||
const rxjsDest = path.join(nodeModulesPath, 'rxjs');
|
||||
fs.symlinkSync(rxjsSource, rxjsDest, 'junction');
|
||||
} catch (e: any) {
|
||||
|
||||
Reference in New Issue
Block a user