Skip to content
This repository was archived by the owner on Aug 20, 2018. It is now read-only.
This repository was archived by the owner on Aug 20, 2018. It is now read-only.

Alternative extensions not getting picked up by the loader? #60

Open
@Panoplos

Description

@Panoplos

Hello, I have json files with the extension .schema that I am attempting to load in a webpack build. The relevant webpack configuration bits are as follows:

...
  resolve: {
    ...
    extensions: ['.js'],
    modules: [path.join(root, 'src'), 'node_modules']
  },
  module: {
    rules: [
      {
        test: /\.(json|schema)$/,
        use: [{ loader: 'json-loader' }]
      },
    ...
  }
}

So, in a source file, when I import .json modules, there is no issue, but when I import a file with the .schema extension, it seems to be parsed by babel, instead, like follows:

const BlockedInfo = require('server/store/schemas/blockedinfo.schema')
1503033073253 - Origin: Worker (PID 13508)
   [Error] SyntaxError: /home/Panoplos/Documents/Development/Node.js/testing-schema/src/server/store/schemas/blockedinfo.schema: Unexpected token, expected ; (2:6)
  1 | {
> 2 |   "$id": "/BlockedInfo",
    |        ^
  3 |   "type": "array",
  4 |   "items": {
  5 |           "type": "object",
    at Parser.pp$5.raise (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:4443:13)
    at Parser.pp.unexpected (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:1755:8)
    at Parser.pp.semicolon (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:1736:38)
    at Parser.pp$1.parseExpressionStatement (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:2230:8)
    at Parser.parseExpressionStatement (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:5817:20)
    at Parser.pp$1.parseStatement (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:1905:17)
    at Parser.parseStatement (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:5795:22)
    at Parser.pp$1.parseBlockBody (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:2262:21)
    at Parser.pp$1.parseBlock (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:2241:8)
    at Parser.pp$1.parseStatement (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:1862:19)
    at Parser.parseStatement (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:5795:22)
    at Parser.pp$1.parseBlockBody (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:2262:21)
    at Parser.pp$1.parseTopLevel (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:1772:8)
    at Parser.parse (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:1667:17)
    at parse (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babylon/lib/index.js:7163:37)
    at File.parse (/home/Panoplos/Documents/Development/Node.js/testing-schema/node_modules/babel-core/lib/transformation/file/index.js:517:15)
1503033073290 - Worker 0 exited - Exit code: 1

Any insights as to why this may be happening will be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions