diff --git a/build-tests/localization-plugin-test-02/build.js b/build-tests/localization-plugin-test-02/build.js new file mode 100644 index 0000000000..eef1c23c1a --- /dev/null +++ b/build-tests/localization-plugin-test-02/build.js @@ -0,0 +1,21 @@ +const { FileSystem } = require('@rushstack/node-core-library'); +const child_process = require('child_process'); +const path = require('path'); +const process = require('process'); + +function executeCommand(command) { + console.log('---> ' + command); + child_process.execSync(command, { stdio: 'inherit' }); +} + +// Clean the old build outputs +console.log(`==> Starting build.js for ${path.basename(process.cwd())}`); +FileSystem.ensureEmptyFolder('dist-dev'); +FileSystem.ensureEmptyFolder('dist-prod'); +FileSystem.ensureEmptyFolder('lib'); +FileSystem.ensureEmptyFolder('temp'); + +// Run Webpack +executeCommand('node node_modules/webpack-cli/bin/cli'); + +console.log(`==> Finished build.js for ${path.basename(process.cwd())}`); diff --git a/build-tests/localization-plugin-test-02/config/rush-project.json b/build-tests/localization-plugin-test-02/config/rush-project.json index 543278bebd..514e557d5e 100644 --- a/build-tests/localization-plugin-test-02/config/rush-project.json +++ b/build-tests/localization-plugin-test-02/config/rush-project.json @@ -4,7 +4,7 @@ "operationSettings": [ { "operationName": "_phase:build", - "outputFolderNames": ["lib", "dist-dev", "dist-prod"] + "outputFolderNames": ["lib", "dist"] } ] } diff --git a/build-tests/localization-plugin-test-02/package.json b/build-tests/localization-plugin-test-02/package.json index abeba748bf..ad191ec69f 100644 --- a/build-tests/localization-plugin-test-02/package.json +++ b/build-tests/localization-plugin-test-02/package.json @@ -4,24 +4,20 @@ "version": "0.1.0", "private": true, "scripts": { - "build": "heft build --clean", - "start": "heft start", - "_phase:build": "heft run --only build -- --clean" + "build": "node build.js", + "serve": "node serve.js", + "_phase:build": "node build.js" }, "dependencies": { - "@rushstack/heft-lint-plugin": "workspace:*", - "@rushstack/heft-localization-typings-plugin": "workspace:*", - "@rushstack/heft-typescript-plugin": "workspace:*", - "@rushstack/heft-webpack4-plugin": "workspace:*", - "@rushstack/heft": "workspace:*", - "@rushstack/node-core-library": "workspace:*", - "@rushstack/set-webpack-public-path-plugin": "^4.1.16", "@rushstack/webpack4-localization-plugin": "workspace:*", "@rushstack/webpack4-module-minifier-plugin": "workspace:*", + "@rushstack/node-core-library": "workspace:*", + "@rushstack/set-webpack-public-path-plugin": "^4.1.16", "@types/lodash": "4.14.116", "@types/webpack-env": "1.18.0", "html-webpack-plugin": "~4.5.2", "lodash": "~4.17.15", + "ts-loader": "6.0.0", "typescript": "~5.4.2", "webpack-bundle-analyzer": "~4.5.0", "webpack-cli": "~3.3.2", diff --git a/build-tests/localization-plugin-test-02/serve.js b/build-tests/localization-plugin-test-02/serve.js new file mode 100644 index 0000000000..ffa5c333f0 --- /dev/null +++ b/build-tests/localization-plugin-test-02/serve.js @@ -0,0 +1,18 @@ +const { FileSystem } = require('@rushstack/node-core-library'); +const child_process = require('child_process'); +const path = require('path'); +const process = require('process'); + +function executeCommand(command) { + console.log('---> ' + command); + child_process.execSync(command, { stdio: 'inherit' }); +} + +// Clean the old build outputs +console.log(`==> Starting build.js for ${path.basename(process.cwd())}`); +FileSystem.ensureEmptyFolder('dist'); +FileSystem.ensureEmptyFolder('lib'); +FileSystem.ensureEmptyFolder('temp'); + +// Run Webpack +executeCommand('node node_modules/webpack-dev-server/bin/webpack-dev-server'); diff --git a/build-tests/localization-plugin-test-02/src/indexA.ts b/build-tests/localization-plugin-test-02/src/indexA.ts index 0f29137534..5609712482 100644 --- a/build-tests/localization-plugin-test-02/src/indexA.ts +++ b/build-tests/localization-plugin-test-02/src/indexA.ts @@ -1,5 +1,5 @@ import { string1 } from './strings1.loc.json'; -import * as strings3 from './strings3.resjson'; +import * as strings3 from './strings3.loc.json'; import * as strings5 from './strings5.resx'; console.log(string1); diff --git a/build-tests/localization-plugin-test-02/src/indexB.ts b/build-tests/localization-plugin-test-02/src/indexB.ts index 3bb70cfd44..ee1d8396f4 100644 --- a/build-tests/localization-plugin-test-02/src/indexB.ts +++ b/build-tests/localization-plugin-test-02/src/indexB.ts @@ -1,4 +1,4 @@ -import { string1, string2 } from './strings3.resjson'; +import { string1, string2 } from './strings3.loc.json'; const strings4: string = require('./strings4.loc.json'); console.log(string1); diff --git a/build-tests/localization-plugin-test-02/src/strings3.loc.json b/build-tests/localization-plugin-test-02/src/strings3.loc.json new file mode 100644 index 0000000000..c85ab94c73 --- /dev/null +++ b/build-tests/localization-plugin-test-02/src/strings3.loc.json @@ -0,0 +1,14 @@ +{ + "string1": { + "value": "string three with a \\ backslash", + "comment": "the third string" + }, + "string2": { + "value": "string four with an ' apostrophe", + "comment": "the fourth string" + }, + "string3": { + "value": "UNUSED STRING", + "comment": "UNUSED STRING" + } +} diff --git a/build-tests/localization-plugin-test-02/webpack.config.js b/build-tests/localization-plugin-test-02/webpack.config.js index 8e5e3800d1..421cb97712 100644 --- a/build-tests/localization-plugin-test-02/webpack.config.js +++ b/build-tests/localization-plugin-test-02/webpack.config.js @@ -12,13 +12,30 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); function generateConfiguration(mode, outputFolderName) { return { mode: mode, + module: { + rules: [ + { + test: /\.tsx?$/, + loader: require.resolve('ts-loader'), + exclude: /(node_modules)/, + options: { + compiler: require.resolve('typescript'), + logLevel: 'ERROR', + configFile: path.resolve(__dirname, 'tsconfig.json') + } + } + ] + }, + resolve: { + extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'] + }, entry: { - 'localization-test-A': `${__dirname}/lib/indexA.js`, - 'localization-test-B': `${__dirname}/lib/indexB.js`, - 'localization-test-C': `${__dirname}/lib/indexC.js` + 'localization-test-A': path.join(__dirname, 'src', 'indexA.ts'), + 'localization-test-B': path.join(__dirname, 'src', 'indexB.ts'), + 'localization-test-C': path.join(__dirname, 'src', 'indexC.ts') }, output: { - path: `${__dirname}/${outputFolderName}`, + path: path.join(__dirname, outputFolderName), filename: '[name]_[locale]_[contenthash].js', chunkFilename: '[id].[name]_[locale]_[contenthash].js' }, @@ -67,17 +84,22 @@ function generateConfiguration(mode, outputFolderName) { normalizeResxNewlines: 'crlf', ignoreMissingResxComments: true }, + typingsOptions: { + generatedTsFolder: path.resolve(__dirname, 'temp', 'loc-json-ts'), + sourceRoot: path.resolve(__dirname, 'src'), + processComment: (comment) => (comment ? `${comment} (processed)` : comment) + }, localizationStats: { - dropPath: `${__dirname}/temp/localization-stats.json` + dropPath: path.resolve(__dirname, 'temp', 'localization-stats.json') }, ignoreString: (filePath, stringName) => stringName === '__IGNORED_STRING__' }), new BundleAnalyzerPlugin({ openAnalyzer: false, analyzerMode: 'static', - reportFilename: `${__dirname}/temp/stats.html`, + reportFilename: path.resolve(__dirname, 'temp', 'stats.html'), generateStatsFile: true, - statsFilename: `${__dirname}/temp/stats.json`, + statsFilename: path.resolve(__dirname, 'temp', 'stats.json'), logLevel: 'error' }), new SetPublicPathPlugin({ diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index 0c0dccf9ef..e8dfbdafb3 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -2070,21 +2070,6 @@ importers: ../../../build-tests/localization-plugin-test-02: dependencies: - '@rushstack/heft': - specifier: workspace:* - version: link:../../apps/heft - '@rushstack/heft-lint-plugin': - specifier: workspace:* - version: link:../../heft-plugins/heft-lint-plugin - '@rushstack/heft-localization-typings-plugin': - specifier: workspace:* - version: link:../../heft-plugins/heft-localization-typings-plugin - '@rushstack/heft-typescript-plugin': - specifier: workspace:* - version: link:../../heft-plugins/heft-typescript-plugin - '@rushstack/heft-webpack4-plugin': - specifier: workspace:* - version: link:../../heft-plugins/heft-webpack4-plugin '@rushstack/node-core-library': specifier: workspace:* version: link:../../libraries/node-core-library @@ -2109,6 +2094,9 @@ importers: lodash: specifier: ~4.17.15 version: 4.17.21 + ts-loader: + specifier: 6.0.0 + version: 6.0.0(typescript@5.4.2) typescript: specifier: ~5.4.2 version: 5.4.2