Skip to content

Commit

Permalink
需要手动允许使用部分模块
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Jul 29, 2024
1 parent 3c0c5f2 commit b26c245
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
"${workspaceFolder}/dist/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
Expand Down
1 change: 1 addition & 0 deletions src/launchGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class GameLauncher {
}
return true;
}
return true;
}

public async launch(luaArgs?: {[key: string]: string|number|boolean}): Promise<boolean> {
Expand Down
14 changes: 10 additions & 4 deletions src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,19 @@ export class PluginManager extends vscode.Disposable {
}
}

private static requireCache: Record<string, any> = {
'y3-helper': y3,
'os': require('os'),
'path': require('path'),
'fs': require('fs'),
'util': require('util'),
'vscode': vscode,
};

private makeSandbox() {
const sandBox = {
require: (name: string) => {
if (name === 'y3-helper') {
return y3;
}
return require(name);
return PluginManager.requireCache[name] ?? require(name);
},
module: { exports: {} },
};
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const config = {
},
resolve: { // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin.TsconfigPathsPlugin({ configFile: path.resolve(__dirname, './tsconfig.json') })]
plugins: [new TsconfigPathsPlugin.TsconfigPathsPlugin({ configFile: path.resolve(__dirname, './tsconfig.json') })],
},
module: {
rules: [{
Expand Down

0 comments on commit b26c245

Please sign in to comment.