This commit is contained in:
Timothee Guerin 2021-11-17 12:12:36 -08:00 коммит произвёл GitHub
Родитель 7b20086e16
Коммит 86d1d0d792
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 58 добавлений и 20 удалений

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/core",
"comment": "**Fix** Sourcemap library fails to load when packed with webpack",
"type": "patch"
}
],
"packageName": "@autorest/core",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "autorest",
"comment": "**Fix** Sourcemap library fails to load when packed with webpack",
"type": "patch"
}
],
"packageName": "autorest",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -75,6 +75,7 @@
"safe-buffer": "5.2.0",
"semver": "^5.5.1",
"source-map-support": "^0.5.19",
"source-map": "0.7.3",
"ts-jest": "^27.0.3",
"ts-loader": "~9.2.3",
"typescript": "~4.4.2",

Просмотреть файл

@ -1,16 +1,11 @@
/* eslint-disable no-process-exit */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/* eslint-disable no-console */
import "source-map-support/register";
const cwd = process.cwd();
import { join } from "path";
import { AutorestSyncLogger, ConsoleLoggerSink, FilterLogger } from "@autorest/common";
import { getLogLevel } from "@autorest/configuration";
import chalk from "chalk";
import { SourceMapConsumer } from "source-map";
import { clearTempData } from "./actions";
import { parseAutorestArgs } from "./args";
import { newCorePackage, ensureAutorestHome, runCoreWithRequire, runCoreOutOfProc } from "./autorest-as-a-service";
@ -18,6 +13,16 @@ import { resetAutorest, showAvailableCoreVersions, showInstalledExtensions } fro
import { VERSION } from "./constants";
import { loadConfig, resolveCoreVersion } from "./utils";
// Need to copy this file in webpack over and tell SourceMapConsumer where it is.
const inWebpack = typeof __webpack_require__ === "function";
if (inWebpack) {
(SourceMapConsumer as any).initialize({
"lib/mappings.wasm": join(__dirname, "mappings.wasm"),
});
}
const cwd = process.cwd();
const isDebuggerEnabled =
// eslint-disable-next-line node/no-unsupported-features/node-builtins
!!require("inspector").url() || global.v8debug || /--debug|--inspect/.test(process.execArgv.join(" "));

Просмотреть файл

@ -33,6 +33,11 @@ module.exports = {
new CopyPlugin({
patterns: [{ from: "node_modules/@autorest/configuration/resources", to: "resources" }],
}),
// We need to copy mappings.wasm so it can be loaded by SourceMapConsumer https://github.com/mozilla/source-map
new CopyPlugin({
patterns: [{ from: "node_modules/source-map/lib/mappings.wasm", to: "mappings.wasm" }],
}),
],
optimization: {
...baseWebpackConfig.optimization,

Просмотреть файл

@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
/* eslint-disable no-console */
import "source-map-support/register";
import { EventEmitter } from "events";
import { resolve as currentDirectory } from "path";
import { join, resolve as currentDirectory } from "path";
import {
configureLibrariesLogger,
color,
@ -16,14 +15,6 @@ import {
IAutorestLogger,
} from "@autorest/common";
import { AutorestCliArgs, parseAutorestCliArgs, getLogLevel } from "@autorest/configuration";
EventEmitter.defaultMaxListeners = 100;
process.env["ELECTRON_RUN_AS_NODE"] = "1";
delete process.env["ELECTRON_NO_ATTACH_CONSOLE"];
// start of autorest-ng
// the console app starts for real here.
import { EnhancedFileSystem, RealFileSystem } from "@azure-tools/datastore";
import {
clearFolder,
@ -35,6 +26,7 @@ import {
writeString,
} from "@azure-tools/uri";
import { omit } from "lodash";
import { SourceMapConsumer } from "source-map";
import { ArtifactWriter } from "./artifact-writer";
import { printAutorestHelp } from "./commands";
import { Artifact } from "./lib/artifact";
@ -44,6 +36,14 @@ import { VERSION } from "./lib/constants";
let verbose = false;
let debug = false;
// Need to copy this file in webpack over and tell SourceMapConsumer where it is.
const inWebpack = typeof __webpack_require__ === "function";
if (inWebpack) {
(SourceMapConsumer as any).initialize({
"lib/mappings.wasm": join(__dirname, "mappings.wasm"),
});
}
async function autorestInit(title = "API-NAME", inputs: Array<string> = ["LIST INPUT FILES HERE"]) {
const cwdUri = createFolderUri(currentDirectory());
for (let i = 0; i < inputs.length; ++i) {

Просмотреть файл

@ -1,8 +1,8 @@
// @ts-check
const path = require("path");
const baseWebpackConfig = require("../../../common/config/webpack.base.config");
const CopyPlugin = require("copy-webpack-plugin");
const baseWebpackConfig = require("../../../common/config/webpack.base.config");
/**
* @type {import("webpack").Configuration}
@ -10,9 +10,9 @@ const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
...baseWebpackConfig,
entry: {
"app": "./src/app.ts",
app: "./src/app.ts",
"language-service": "./src/language-service/language-service.ts",
"exports": "./src/exports.ts",
exports: "./src/exports.ts",
},
output: {
...baseWebpackConfig.output,
@ -35,6 +35,11 @@ module.exports = {
new CopyPlugin({
patterns: [{ from: "node_modules/@autorest/configuration/resources", to: "resources" }],
}),
// We need to copy mappings.wasm so it can be loaded by SourceMapConsumer https://github.com/mozilla/source-map
new CopyPlugin({
patterns: [{ from: "node_modules/source-map/lib/mappings.wasm", to: "mappings.wasm" }],
}),
],
optimization: {
...baseWebpackConfig.optimization,