microsoft / vscode-nls-dev

The tools automates the extraction of strings to be externalized from TS and JS code. It therefore help localizing VSCode extensions and language servers written in TS and JS
Other
39 stars 37 forks source link

Unable to bundle library which uses nls #26

Closed arhelmus closed 4 years ago

arhelmus commented 4 years ago

Hey, I trying to create a plugin on top of vscode-chrome-debug-core, which uses nls to handle translations. When I bundle my plugin with webpack using nls-dev bundler and loader, it does not import translations of vscode-chrome-debug-core dependency. As a result, I see "Failed to load message bundle..." message in my extension.

Is it possible to bundle dependency translations as part of my extension?

const config = {
  target: 'node',

  node: {
    __dirname: false
  },

  entry: './src/extension.ts',

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'extension.js',
    libraryTarget: 'commonjs2',
    devtoolModuleFilenameTemplate: '../[resource-path]',
  },

  devtool: 'source-map',

  externals: [{
    vscode: 'commonjs vscode',
  }],

  resolve: {
    extensions: ['.ts', '.js'],
    plugins: [
      new TsconfigPathsPlugin({
        configFile: path.resolve(__dirname, '..', '..', 'tsconfig.json'),
      }),
    ],
  },

  plugins: [
    new NLSBundlePlugin('reactvr-vscode-plugin'),
  ],

  module: {
    rules: [
      {
        test: /\.ts$/,
        exclude: /node_modules/,
        use: [{
                    loader: 'vscode-nls-dev/lib/webpack-loader',
                    options: {
                        base: path.join(__dirname, 'src')
                    }
                }, {
                    loader: 'ts-loader',
                }]
      },
    ],
  },
};
arhelmus commented 4 years ago

@roblourens I saw that you managed to bundle translations from vscode-chrome-debug-core as part of vscode-chrome-debug plugin, how did you managed to do this?

arhelmus commented 4 years ago

Actually, I figured out that vscode-chrome-debug not bundle dependencies and package those in vsix. Will follow this way, sorry for bothering.

roblourens commented 4 years ago

Exactly - I looked into doing this and had the same issue. I don't think it's possible right now.