Skip to content

include source type fails schema validation #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lopopolo opened this issue Feb 15, 2021 · 3 comments
Closed

include source type fails schema validation #359

lopopolo opened this issue Feb 15, 2021 · 3 comments

Comments

@lopopolo
Copy link

  • Operating System: Arch Linux
  • Node Version: v14.15.4
  • NPM Version: 6.14.11
  • webpack Version: 5.21.2
  • html-loader Version: 2.0.0

Expected Behavior

Configuring html-loader to include partials adds the HTML to the index.html

Actual Behavior

ERROR in   Error: Child compilation failed:
  Module build failed (from ../node_modules/html-loader/dist/cjs.js):
  ValidationError: Invalid options object. HTML Loader has been initialized using an options object that does not match the API sc  hema.
   - options.sources.list[1].type should be one of these:
     "src" | "srcset"
  
  - validate.js:104 validate
    [www.artichokeruby.org]/[schema-utils]/dist/validate.js:104:11
  
  - NormalModule.js:425 Object.getOptions
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:425:6
  
  - index.js:17 Object.loader
    [www.artichokeruby.org]/[html-loader]/dist/index.js:17:27
  
  - ModuleBuildError: Module build failed (from ../node_modules/html-loader/dist/cjs.js):
  
  - ValidationError: Invalid options object. HTML Loader has been initialized using an options object that does not match the API     schema.
  
  - - options.sources.list[1].type should be one of these:
  
  - "src" | "srcset"
  
  - validate.js:104 validate
    [www.artichokeruby.org]/[schema-utils]/dist/validate.js:104:11
  
  - NormalModule.js:425 Object.getOptions
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:425:6
  
  - index.js:17 Object.loader
    [www.artichokeruby.org]/[html-loader]/dist/index.js:17:27
  
  - NormalModule.js:598 processResult
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:598:19
  
  - NormalModule.js:692 
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:692:5
  
  - LoaderRunner.js:399 
    [www.artichokeruby.org]/[loader-runner]/lib/LoaderRunner.js:399:11
  
  - LoaderRunner.js:251 
    [www.artichokeruby.org]/[loader-runner]/lib/LoaderRunner.js:251:18
  
  - Module build failed (from ../node_modules/html-loader/dist/cjs.js):
  
  - ValidationError: Invalid options object. HTML Loader has been initialized using an options object that does not match the API     schema.
  
  - - options.sources.list[1].type should be one of these:
  
  - "src" | "srcset"
  
  - validate.js:104 validate
    [www.artichokeruby.org]/[schema-utils]/dist/validate.js:104:11
  
  - NormalModule.js:425 Object.getOptions
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:425:6
  
  - index.js:17 Object.loader
    [www.artichokeruby.org]/[html-loader]/dist/index.js:17:27
  
  - ModuleBuildError: Module build failed (from ../node_modules/html-loader/dist/cjs.js):
  
  - ValidationError: Invalid options object. HTML Loader has been initialized using an options object that does not match the API     schema.
  
  - - options.sources.list[1].type should be one of these:
  
  - "src" | "srcset"
  
  - validate.js:104 validate
    [www.artichokeruby.org]/[schema-utils]/dist/validate.js:104:11
  
  - NormalModule.js:425 Object.getOptions
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:425:6
  
  - index.js:17 Object.loader
    [www.artichokeruby.org]/[html-loader]/dist/index.js:17:27
  
  - NormalModule.js:598 processResult
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:598:19
  
  - NormalModule.js:692 
    [www.artichokeruby.org]/[webpack]/lib/NormalModule.js:692:5
  
  - LoaderRunner.js:399 
    [www.artichokeruby.org]/[loader-runner]/lib/LoaderRunner.js:399:11
  
  - LoaderRunner.js:251 
    [www.artichokeruby.org]/[loader-runner]/lib/LoaderRunner.js:251:18
  
  - child-compiler.js:159 
    [www.artichokeruby.org]/[html-webpack-plugin]/lib/child-compiler.js:159:18
  
  - Compiler.js:513 
    [www.artichokeruby.org]/[webpack]/lib/Compiler.js:513:11
  
  - Compiler.js:1065 
    [www.artichokeruby.org]/[webpack]/lib/Compiler.js:1065:17
  
  
  - Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
    [www.artichokeruby.org]/[tapable]/lib/Hook.js:18:14
  
  - Compiler.js:1061 
    [www.artichokeruby.org]/[webpack]/lib/Compiler.js:1061:33
  
  - Compilation.js:2413 
    [www.artichokeruby.org]/[webpack]/lib/Compilation.js:2413:11
  
  
  - Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
    [www.artichokeruby.org]/[tapable]/lib/Hook.js:18:14
  
  - Compilation.js:2406 
    [www.artichokeruby.org]/[webpack]/lib/Compilation.js:2406:38
  


2 ERRORS in child compilations
webpack 5.21.2 compiled with 4 errors and 1 warning in 2157 ms

Code

        {
          test: /\.html$/i,
          loader: "html-loader",
          options: {
            sources: {
              list: [
                "...",
                {
                  tag: "include",
                  attribute: "src",
                  type: "include",
                },
              ],
            },
          },
        },

How Do We Reproduce?

https://github.com/artichoke/www.artichokeruby.org/tree/da016d3d1fcef42ab0e4fb27085280ef87b0ecbb

$ npx webpack build
@alexander-akait
Copy link
Member

include is never supported and doesn't work for v1 or v2, but with the new release (v2), it is possible, I will improve this in the near future, let's close in favor #291

@lopopolo
Copy link
Author

@alexander-akait I did manage to get this to work by requireing the partial with an html-loader!, but the partial doesn't get inlined into the source and instead shows up as [Module object] or something like that. Is there an example of requiring an html partial and inlining it into an html page?

@alexander-akait
Copy link
Member

Is there an example of requiring an html partial and inlining it into an html page?

No, because it is not supported by v1 and v2, it is non standard for HTML, but I am working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants