Skip to content

Commit

Permalink
Attempt to fix an issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Aug 21, 2024
1 parent a9747a4 commit c6312e6
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 35 deletions.
21 changes: 21 additions & 0 deletions build-tests/localization-plugin-test-02/build.js
Original file line number Diff line number Diff line change
@@ -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())}`);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"operationSettings": [
{
"operationName": "_phase:build",
"outputFolderNames": ["lib", "dist-dev", "dist-prod"]
"outputFolderNames": ["lib", "dist"]
}
]
}
16 changes: 6 additions & 10 deletions build-tests/localization-plugin-test-02/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions build-tests/localization-plugin-test-02/serve.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion build-tests/localization-plugin-test-02/src/indexA.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion build-tests/localization-plugin-test-02/src/indexB.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
14 changes: 14 additions & 0 deletions build-tests/localization-plugin-test-02/src/strings3.loc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
36 changes: 29 additions & 7 deletions build-tests/localization-plugin-test-02/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
Expand Down Expand Up @@ -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({
Expand Down
18 changes: 3 additions & 15 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6312e6

Please sign in to comment.