diff --git a/.eslintrc b/.eslintrc
index b0f479e..e8d8b5d 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -32,8 +32,9 @@
}],
"import/extensions": ["error", {
"js": "never",
- "ts": "never",
- }]
+ "ts": "never"
+ }],
+ "class-methods-use-this": "off"
},
"overrides": [
{
@@ -51,7 +52,7 @@
"airbnb-base",
"plugin:jest/recommended",
"plugin:@typescript-eslint/eslint-recommended",
- "plugin:@typescript-eslint/recommended",
+ "plugin:@typescript-eslint/recommended"
],
"env": { "node": true },
"rules": {
@@ -59,7 +60,7 @@
"no-console": ["off"],
"import/extensions": ["error", {
"js": "never",
- "ts": "never",
+ "ts": "never"
}]
}
}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 04334c6..7385a02 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,10 +13,11 @@ on:
jobs:
test:
name: Test
- runs-on: ubuntu-latest
strategy:
matrix:
- node-version: [14.x, 16.x, 18.x]
+ node-version: [14.x, 16.x, 18.x, 20.x]
+ os: [ubuntu-latest, windows-latest, macos-latest]
+ runs-on: ${{ matrix.os }}
env:
HUSKY: 0
steps:
@@ -28,6 +29,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
+ shell: bash
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@v3
diff --git a/.npmignore b/.npmignore
index a47439f..f26786a 100755
--- a/.npmignore
+++ b/.npmignore
@@ -15,3 +15,4 @@ yarn.lock
.husky
/scripts
jest.config.js
+docs
diff --git a/README.md b/README.md
index 1a8eba4..88a9859 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,10 @@ module.exports = {
};
```
+## Known limitations
+1. This plugin does not transform Web Worker syntax like `new Worker(new URL('./worker.js', import.meta.url));``. It simply embeds the source code processed by webpack into HTML files, and emits any JavaScript files that is not processed by the plugin.
+2. This plugin is designed to embed script content into HTML files for deployment to environments where only a single file can be uploaded, or where the script file itself is small enough that it doesn't warrant an additional HTTP request. It is not intended for use in development, and may fail if HMR is enabled.
+
## Contributors
Thanks goes to these wonderful people:
@@ -145,7 +149,7 @@ Thanks goes to these wonderful people:
-
+
@SorsOps
diff --git a/__tests__/HtmlInlineScriptPlugin.test.ts b/__tests__/HtmlInlineScriptPlugin.test.ts
index 1596ead..2ac0e78 100644
--- a/__tests__/HtmlInlineScriptPlugin.test.ts
+++ b/__tests__/HtmlInlineScriptPlugin.test.ts
@@ -9,12 +9,12 @@ import preserveConfig from './cases/preserveAsset/webpack.config';
import multipleInstanceConfig from './cases/multiple-instance/webpack.config';
import jsWithImportConfig from './cases/js-with-import/webpack.config';
import webWorkerConfig from './cases/web-worker/webpack.config';
-import inlineWebWorkerConfig from './cases/inline-web-worker/webpack.config';
import ignoreScriptsConfig from './cases/ignore-scripts/webpack.config';
import ignoreHtmlsConfig from './cases/ignore-htmls/webpack.config';
import ignoreScriptsAndHtmlsConfig from './cases/ignore-scripts-and-htmls/webpack.config';
import filenameWithSpecialCharactersConfig from './cases/filename-with-special-characters/webpack.config';
import escapeScriptTagEndConfig from './cases/escape-script-end-tag/webpack.config';
+import htmlInsideSubfolderConfig from './cases/html-inside-subfolder/webpack.config';
describe('HtmlInlineScriptPlugin', () => {
it('should build simple webpack config without error', async () => {
@@ -206,9 +206,9 @@ describe('HtmlInlineScriptPlugin', () => {
await webpackPromise;
});
- it('should build webpack config having inline web worker without error', async () => {
+ it('should build webpack config that outputs html file inside subfolder without error', async () => {
const webpackPromise = new Promise((resolve) => {
- const compiler = webpack(inlineWebWorkerConfig);
+ const compiler = webpack(htmlInsideSubfolderConfig);
compiler.run((error, stats) => {
expect(error).toBeNull();
@@ -216,21 +216,24 @@ describe('HtmlInlineScriptPlugin', () => {
const statsErrors = stats?.compilation.errors;
expect(statsErrors?.length).toBe(0);
- const result1 = fs.readFileSync(
- path.join(__dirname, 'cases/inline-web-worker/dist/index.html'),
+ const result = fs.readFileSync(
+ path.join(__dirname, 'cases/html-inside-subfolder/dist/frontend/index.html'),
'utf8',
);
- const expected1 = fs.readFileSync(
- path.join(__dirname, 'cases/inline-web-worker/expected/index.html'),
+ const expected = fs.readFileSync(
+ path.join(__dirname, 'cases/html-inside-subfolder/expected/frontend/index.html'),
'utf8',
);
+ expect(result).toBe(expected);
- expect(result1).toBe(expected1);
+ const expectedParentFileList = fs.readdirSync(path.join(__dirname, 'cases/html-inside-subfolder/expected/'));
+ const generatedParentFileList = fs.readdirSync(path.join(__dirname, 'cases/html-inside-subfolder/dist/'));
+ expect(expectedParentFileList.sort()).toEqual(generatedParentFileList.sort());
- const expectedFileList = fs.readdirSync(path.join(__dirname, 'cases/inline-web-worker/expected/'));
- const generatedFileList = fs.readdirSync(path.join(__dirname, 'cases/inline-web-worker/dist/'));
- expect(expectedFileList.sort()).toEqual(generatedFileList.sort());
+ const expectedChildFileList = fs.readdirSync(path.join(__dirname, 'cases/html-inside-subfolder/expected/'));
+ const generatedChildFileList = fs.readdirSync(path.join(__dirname, 'cases/html-inside-subfolder/dist/'));
+ expect(expectedChildFileList.sort()).toEqual(generatedChildFileList.sort());
resolve(true);
});
diff --git a/__tests__/cases/html-inside-subfolder/expected/frontend/index.html b/__tests__/cases/html-inside-subfolder/expected/frontend/index.html
new file mode 100644
index 0000000..bbe46c3
--- /dev/null
+++ b/__tests__/cases/html-inside-subfolder/expected/frontend/index.html
@@ -0,0 +1 @@
+webpack test This is minimal code to demonstrate webpack usage
\ No newline at end of file
diff --git a/__tests__/cases/inline-web-worker/fixtures/index.html b/__tests__/cases/html-inside-subfolder/fixtures/index.html
similarity index 91%
rename from __tests__/cases/inline-web-worker/fixtures/index.html
rename to __tests__/cases/html-inside-subfolder/fixtures/index.html
index a2e082c..c061c8e 100644
--- a/__tests__/cases/inline-web-worker/fixtures/index.html
+++ b/__tests__/cases/html-inside-subfolder/fixtures/index.html
@@ -10,6 +10,5 @@
This is minimal code to demonstrate webpack usage
- Run Action