@@ -2,9 +2,10 @@ const webpack = require("webpack");
22const path = require ( "path" ) ;
33const HtmlWebpackPlugin = require ( "html-webpack-plugin" ) ;
44const PnpWebpackPlugin = require ( "pnp-webpack-plugin" ) ;
5+ // Not used directly in playground, because it imports typescript
6+ const { SyntaxKind : LuaSyntaxKind } = require ( "typescript-to-lua/dist/LuaAST" ) ;
57
68const resolve = query => path . resolve ( __dirname , query ) ;
7- const emptyModulePath = require . resolve ( "node-libs-browser/mock/empty.js" ) ;
89
910/** @type {import("webpack").Configuration } */
1011module . exports = {
@@ -18,6 +19,12 @@ module.exports = {
1819 resolve : {
1920 extensions : [ ".tsx" , ".ts" , ".js" ] ,
2021 plugins : [ PnpWebpackPlugin ] ,
22+ alias : {
23+ // Replace vendored `monaco-typescript` services build with `typescript`, already used by `typescript-to-lua`
24+ [ require . resolve ( "monaco-editor/esm/vs/language/typescript/lib/typescriptServices.js" ) ] : require . resolve (
25+ "typescript" ,
26+ ) ,
27+ } ,
2128 } ,
2229 resolveLoader : {
2330 plugins : [ PnpWebpackPlugin . moduleLoader ( module ) ] ,
@@ -53,23 +60,9 @@ module.exports = {
5360 contentFile : "play.html" ,
5461 } ) ,
5562
56- // Ignore pnpapi reference in patched typescript source
57- new webpack . IgnorePlugin ( / p n p a p i / ) ,
58-
59- new webpack . NormalModuleReplacementPlugin ( / t y p e s c r i p t / , resource => {
60- // Exclude `typescript` from `play_bundle` referenced from `typescript-to-lua/dist/LuaAST`
61- const { issuer, compiler } = ( resource . resourceResolveData && resource . resourceResolveData . context ) || { } ;
62- if ( issuer === require . resolve ( "typescript-to-lua/dist/LuaAST" ) && compiler !== "worker" ) {
63- resource . resource = emptyModulePath ;
64- }
63+ new webpack . DefinePlugin ( { __LUA_SYNTAX_KIND__ : JSON . stringify ( LuaSyntaxKind ) } ) ,
6564
66- // Replace vendored monaco-typescript's services build with full TypeScript API.
67- if (
68- resource . resource ===
69- require . resolve ( "monaco-editor/esm/vs/language/typescript/lib/typescriptServices.js" )
70- ) {
71- resource . request = require . resolve ( "typescript" ) ;
72- }
73- } ) ,
65+ // Ignore `pnpapi` reference in patched `typescript` source
66+ new webpack . IgnorePlugin ( / p n p a p i / ) ,
7467 ] ,
7568} ;
0 commit comments