webpack-contrib / json-loader Goto Github PK
View Code? Open in Web Editor NEWjson loader module for webpack - UNMAINTAINED
License: MIT License
json loader module for webpack - UNMAINTAINED
License: MIT License
Webpack version: 0.12.2
I'm getting this error:
ERROR in dir/~/json-loader!dir/embedded/config.json
Module build failed: SyntaxError: Unexpected token m
at Object.parse (native)
at Object.module.exports (dir/node_modules/json-loader/index.js:7:48)
@ dir/embedded/includers/index.js 12:21-51
and in the includers/index.js
I have this line:
var embeddedConfig = require("json!../config.json");
After checking, the problem is that the json-loader gets called two times, and the first one returns the expected outcome: "module.exports = {....}"
but the second time it has "module.exports = {....}"
as a source, so it tries to parse the string to JSON and then it fails because it's not a valid JSON.
Is anyone else getting the same error or did I do something wrong in the configuration?
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.
This is what I'm getting:
ERROR in ./src/components/config.json
Module build failed: SyntaxError: Unexpected token m
at Object.parse (native)
at Object.module.exports (/Users/me/my-project/node_modules/json-loader/index.js:7:48)
@ ./src/components/Main.js 28:13-37
The relevant JSON file I'm trying to load:
{
"redirectUri": "http://localhost:8000/webpack-dev-server/"
}
I'm requiring it via var Config = require('./config.json');
. I had the same error when I did require('json!./config.json')
.
I have this in my list of loaders
:
{
test: /\.json$/,
loader: 'json-loader!json-loader'
}
I got the same error when I moved the loader to the preLoaders
section.
This is the version I'm using: "json-loader": "^0.5.4"
.
I would like to release a version to fix a loader error. Already I created a branch, but I can not do pull request (perhaps not have permission). Who can help me? The fix is ββto avoid the error "Unexpected token m in JSON at position 0" that the loader generates the Angular 2 project
(node:38259) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Module '/node_modules/json-loader/index.js' is not a loader (must have normal or pitch function)
webpack@^2.1.0-beta.25
Preface: there's a lot going on here. :/
I tried to be clever and use the package name as a CSS Prefix with @thompsongl's https://github.com/thompsongl/postcss-class-prefix.
"postcss-class-prefix": "^0.3.0",
"postcss-loader": "^0.13.0",
"json-loader": "^0.5.4",
"webpack": "^2.1.0-beta.25"
$ webpack --progress -p
15% building modules 42/55 modules 13 active ...de_modules/css-loader/lib/css-base.js(node:73866) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Module '/Users/kevinSuttle/Code/ui-primitives-react/node_modules/json-loader/index.js' is not a loader (must have normal or pitch function)
21% building modules 94/95 modules 1 active ...Code/ui-primitives-react/package.json
$ nvm current
v6.7.0
webpack.config.js
const pkg = require('./package.json');
const CssClassPrefix = `${pkg.name.split('/')[1]}_`;
// require(!json.package.json) results in
// Error: Cannot find module 'json!./package.json'
// ...
new webpack.LoaderOptionsPlugin({
options: {
postcss: function (webpack) {
return [
require('postcss-import')({
addDependencyTo: webpack,
}),
customProperties(),
cssApply,
autoprefixer,
postCSSPrefix(CssClassPrefix),
]
},
},
}
Even tried the suggestions in webpack-contrib/css-loader#145 of adding require('es6-promise')
at the top of webpack.config.js, but no dice.
Seems like a race condition, but I can't be sure.
In the README the npm command says --save
which saves the dependency to dependencies
in package.json
. I can only think of use cases where I'd want to save it as a development dependency, i.e. I'd install it as npm install --save-dev json-loader
.
So my question, why would you need this as a regular dependency?
I'm happy to see that json-loader
works automatically in webpack 2 πΈ https://webpack.js.org/guides/migrating/#json-loader-is-not-required-anymore.
When no loader has been configured for a JSON file, webpack will automatically try to load the JSON file with the json-loader.
My question though, is there any reason (besides if you have different file extensions) to explicitly write this in the config?
I am using Webpack version 1 and had to use the plugin to load a json file.
For some reason I was not getting anything to work until reading this Stack Overflow answer, which had different configuration (essentially different key names in the object).
Please add a warning or at least say in the README that those are instructions for Webpack 2. It would also be nice to have installation instructions for webpack v1 (if they are not already here somewhere?).
Webpack v2 config (shown in README):
module: {
rules: [
{
test: /\.json$/,
use: 'json-loader'
}
]
}
Webpack v1 config (not mentioned anywhere in the README)
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
}
]
}
in v1, not rules, but loaders; not use, but loader
thx
how to exclude jsons in specific folder for json-loader
test: /\.json$/,
use: ['json-loader'],
exclude: excludeil18Dir
I want to read mongo from URL in a React component:
$ mongo ec2-XX-XX-X-XXX.us-west-2.compute.amazonaws.com:27017
is this the correct package for this job? If not could you point out the relevant package for doing so programmatically?
Add a flag/option to use the new export syntax added in ES2015 instead of module.exports.
Tools like babel used for post-processing might not be configured to recognize both module.exports/require and export/import.
This is a low priority issue, though should be (I think) easy to add.
Hi folks,
I wanted to share one concern with you.
Our .json
file couldn't be processed due to some issue with Unicode encoding. Apparently, we had a Line Separator char in the string literal. It was invisible in our text editors and we found with an empirical approach. I found that answer on SO that explains why javascript fails to parse it.
I just think that it would be great to automatically escape this char in json-loader
somehow. Or let a user know about the possible problem. What do you think?
Addition of webpack-defaults
& associated refactoring as a part of the next Major
release
Issue exists for status tracking across the organization.
Please do not close
Hi, I want to use json-loader
with ExtractTextPlugin
like this config:
rule: {
test: /\.json$/,
loader: ExtractJSON.extract({
loader: [{
loader: 'json-loader'
}]
})
}
That was throw this error:
ERROR in ./src/index.json
Module build failed: TypeError: text.forEach is not a function
at Object.<anonymous> (\node_modules\extract-text-webpack-plugin\loader.js:109:10)
at Compiler.<anonymous> (\node_modules\webpack\lib\Compiler.js:280:10)
at \node_modules\webpack\lib\Compiler.js:480:13
...
I change the json-loader return value as:
// json-loader/index.js
return "module.exports = " + '`' + JSON.stringify(value, undefined, "\t") + '`' + ";";
It's works fine, but I think it's not a good idea. Anything help for this problem ?
Thanks :)
Don't forget to polyfill require if you want to use it in node. See webpack documentation.
Since the webpack documentation isn't doing anyone any favours, it would be great if README could link to a relevant page (target documentation page, issue discussion about target) and explain something like
When compiling with "node" as a target, require('package.json') will expect the file (package.json, in this case) to be a real, parseable JS file with a
module.exports
. Adding JSON loader will export the parsed JSON as a real object.
This statement is absolutely not what someone who's looking for information on why loading json isn't working hopes to find. It just makes them more angry because no one's explaining how the hell to use this loader =)
Cannot find module '../maps/decode.json' from 'decode_codepoint.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)
at Object. (node_modules/entities/lib/decode_codepoint.js:1:106)
module.exports = {
entry: path.resolve('./client/public/index.js'),
output: {
path: path.resolve('./client/public/'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /.js[x]?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['react', 'env', "es2015"]
}
},
{
test: /.json$/,
include: [
/node_modules/,
path.resolve(__dirname, '..')
],
loader: 'json-loader'
}
]
},
resolve: {
extensions: ['.js', '.jsx']
}
}
I'm attempting to use a number of libraries which internally require JSON files but do so without specifying the .json
file extension so I'm having difficulties in setting up my loader. e.g.
e.g.
var listData = require('./list');
where list refers to a list.json
in the package root. If I manually edit the index.js to var listData = require('./list.json');
then everything works as expected but editing the contents of a 3rd party library isn't a long-term solution. My JSON loader is currently configured like so:
module.exports = {
test: /\.json$/,
loader: 'json-loader'
}
Is there an alternative configuration I should be using in order to utilize npm packages using JSON requires without an extension?
So if I provide a json file this loader parses it into a javascript object?
If yes how would other javascript code access this object? is it in the global namespace? window.myJsonObj
Thanks
I'm not sure if I understand the docs correctly, but shouldn't the json-loader try to read from inputValues
first?
I'm using @okonet's yaml-loader which returns the parsed yaml as json string. After that the json-loader re-parses the string which is unnecessary.
I`m trying to build angular with webpack, and this is what i have, can somebody help me?
'use strict';
var path = require('path');
var webpack = require('webpack');
module.exports = {
context: path.join(__dirname, '/'),
entry: {
app: ['./app/main.ts']
},
output: {
path: path.join(__dirname, 'server/public/javascripts'),
filename: '[name].js'
},
resolve: {
extensions: ['', '.ts', '.js', '.json']
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json' },
{ test: /\.ts$/, loader: 'ts-loader'}
]
},
plugins: [
new webpack.ProvidePlugin({
'System': require('systemjs')
})
]
};
Module parse failed: /home/sergey/projects/vk-app/node_modules/ts-loader/index.js!/home/sergey/projects/vk-app/app/main.ts Converting circular structure to JSON
You may need an appropriate loader to handle this file type.
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at Parser.<anonymous> (/home/sergey/projects/vk-app/node_modules/webpack/lib/ProvidePlugin.js:36:86)
at Parser.applyPluginsBailResult (/home/sergey/projects/vk-app/node_modules/webpack/node_modules/tapable/lib/Tapable.js:48:50)
at Parser.walkIdentifier (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:684:21)
at Parser.walkExpression (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:513:40)
at Parser.walkMemberExpression (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:677:7)
at Parser.walkExpression (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:513:40)
at Parser.walkCallExpression (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:657:9)
at Parser.walkExpression (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:513:40)
at Parser.walkExpressionStatement (/home/sergey/projects/vk-app/node_modules/webpack/lib/Parser.js:360:7)
@ multi app
When I run this json through the json-loader:
https://github.com/fb55/htmlparser2/blob/master/lib/entities/entities.json
I get:
63: function(module) {
module.exports = {
quot: 34,
amp: 38,
apos: 39,
lpar: 40,
rpar: 41,
lt: 60,
gt: 62,
nbsp: 160,
iexcl: 161
...
}
}
It looks like the escaped unicode code points are being lost. I'm not exactly sure what the resulting values are, but it is neither the unescaped unicode characters nor the escaped code point sequences.
It's interesting that quot became "34" instead of just """, which is technically the correct ASCII value, but the json-loader should not be doing such conversions.
The README just shows a weird require("json!./file.json");
statement. I want it to work like it does in node.
Please could we have some examples, both for config file and command line usage.
I am trying the following, but it results in an error:
$ webpack --entry ./foo.js --output-filename server.js --module-bind json
/home/simon/npm/lib/node_modules/webpack/lib/NormalModuleFactory.js:217
return callback(null, Object.assign({}, item, {
^
TypeError: Object function Object() { [native code] } has no method 'assign'
at /home/simon/npm/lib/node_modules/webpack/lib/NormalModuleFactory.js:217:33
at onResolved (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:72:10)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at innerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:122:22)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at /home/simon/npm/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:210:15
at /home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:38:22
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at innerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:122:22)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at /home/simon/npm/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:210:15
at innerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:122:22)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at /home/simon/npm/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:210:15
at /home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:42:23
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at afterInnerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:135:22)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at next (/home/simon/npm/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:112:35)
at /home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:21:36
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at innerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:122:22)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at /home/simon/npm/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:210:15
at innerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:122:22)
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at /home/simon/npm/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:210:15
at /home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js:29:14
at loggingCallbackWrapper (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
at innerCallback (/home/simon/npm/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:122:22)
Thanks.
Should the returned value really be constructed with JSON.stringify(value, undefined, "\t")
? Specifically the "\t"
could be problematic, and slow down webpack. What's wrong with using something else, such as source
for example?
In my project, I'm loading a JSON file that contains a 512x512 matrix of data. In my original file, this takes up 512 lines of text. However, the json-loader's use of JSON.stringify(value, undefined, "\t")
is causing this matrix to now consume approximately 262144 lines of text. This seems to be causing webpack to take longer then necessary.
When running a webpack watch using the json-loader as is, it would take each recompile of my project approximately 6 seconds. When replacing the usage of JSON.stringify(value, undefined, "\t")
with source
or JSON.stringify(value)
, this is reduced to approximately 1 second.
Perhaps the usage of "\t"
could be configured via a query option?
We're running both linux and windows set-ups, depending on the order in which json-loader
is included in the rules, on different operating systems, it will either pass or fail.
This order works on linux, but fails on windows.
{
test: /\.json$/,
use: ['json-loader']
},
{
test : /\.jsx?/,
// include: APP_DIR,
exclude: /node_modules\/(?!ayvri-*)/,
use: 'babel-loader',
},
This fails on linux but work on windows
{
test: /\.json$/,
use: ['json-loader']
},
{
test : /\.jsx?/,
// include: APP_DIR,
exclude: /node_modules\/(?!ayvri-*)/,
use: 'babel-loader',
},
In case you want our full webpack, it's
var webpack = require('webpack');
var path = require('path');
var APP_DIR = path.resolve(__dirname, 'src');
var BUILD_DIR = path.resolve(__dirname, 'public');
var config = {
entry: {
bundle: APP_DIR + '/index.js',
workers: APP_DIR + '/workers/index.js',
clientAPI: APP_DIR + '/util/clientAPI.js'
},
output: {
path: BUILD_DIR,
filename: '[name].js',
publicPath: 'https://localhost:3000',
library: 'AyvriClientAPI'
},
module : {
rules : [
{
test: /\.json$/,
use: ['json-loader']
},
{
test : /\.jsx?/,
// include: APP_DIR,
exclude: /node_modules\/(?!ayvri-*)/,
use: 'babel-loader',
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'assetPath': '"//s3.amazonaws.com/doarama-viewer-production"',
'NODE_ENV': '"production"'
}
}),
new webpack.SourceMapDevToolPlugin({
filename: '[name].js.map'
})
]
};
module.exports = config;
import {author} from '../package.json'
console.log(author)
Doing it like this doesn't work
The default way it import specific parts of a json file works without warnings like this and it returns undefined after
I can import the whole json by not destructuring it
like this
import author from '../package.json'
console.log(author)
Thank you for this!
Since node 5 it is possible to just require .json files (see discussion e.g. webpack/webpack#184 and https://github.com/nodejs/node-v0.x-archive/blob/master/lib/module.js#L485 )
To reflect that, it would be nice if the README.md could point out that the same syntax (require('sample.json')
) can be used, using this loader by adding
module: {
loaders: [
{
test: /\.json$/,
loader: 'json'
}]
}
to your Webpack configuration file. It took me a while to figure that out while require
-ing node 5 modules.
Hi, I am trying this, I am confident my paths are correct
var Page = require('json!./json/foo.json');
and get this error
ERROR in ../mocks/mockApi.js
Module not found: Error: Cannot resolve module 'json' in /Users/me/ui/src/components/native/mocks
@ ../mocks/mockApi.js 1:31-83
We are seeing this warning on CI trying to update Create React App to Webpack 3: facebook/create-react-app#2574 (comment). However we never explicitly use json-loader
.
I wonder if it's possible that the warning has a false positive? For example webpack/webpack#3374 makes webpack delegate to json-loader
automatically here. Is there any chance that this could unintentionally trigger the warning?
Example :
sample.json
{
"key1": "value1",
"key2": "value2"
}
Usage
let data = require('./sample.json');
console.log(data);
With json-loader 0.5.4
{
"key1": "value1",
"key2": "value2"
}
With json-loader 0.5.5 : It is adding a wrapper object with key : 'default'.
{
"default": {
"key1": "value1",
"key2": "value2"
}
}
With this existing code is breaking.
FYI : Using https://github.com/AngularClass/angular-starter
module.exports = function(source) {
this.cacheable && this.cacheable();
console.log(source);
var value = typeof source === "string" ? JSON.parse(source) : source;
this.value = [value];
return "module.exports = " + JSON.stringify(value, undefined, "\t") + ";";
}
console.log output
{}
module.exports = {};
Error: Unexpected token m in JSON at position 0
Webpack config
var webpack = require('webpack');
module.exports = {
entry: './app/driver.js',
externals: {
'jquery': '$'
},
module: {
loaders: [
{
test: /\.json$/,
loader: "json-loader"
},
{
test: /\.html$/,
loader: 'underscore-template-loader'
}
]
},
output: {
path: __dirname + '/static/js',
filename: 'bundle.js'
},
plugins: [
new webpack.ProvidePlugin({
_: 'underscore'
})
],
resolve: {
modulesDirectories: [__dirname + '/node_modules'],
root: __dirname + '/app'
},
resolveLoader: {
root: __dirname + '/node_modules'
}
};
node v6.0.0
'use strict';
const webpack = require("webpack");
const path = require('path');
module.exports = {
entry: {
app: './build/aws.js',
libraries: ['./src/libraries.js']
},
resolve: {
modules: [
'node_modules',
path.resolve('./build'),
path.resolve('.'),
path.resolve('../../../lib')
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'libraries',
filename: 'lib.bundle.js'
})
],
output: {
path: './dist',
filename: 'bundle.js'
},
rules: [
{
test: /.json$/,
use: 'json-loader'
}
],
loaders:[
{ test: /vendor\/.+\.(jsx|js)$/,
loader: 'imports?jQuery=jquery,$=jquery,this=>window',
},
]
};
AWS.JSX
import foo from 'foo.json'
Title speaks for itself I think. There are two possible scenario's:
I think it would be convinient to use json.minify to enable and then remove the comments before parsing in json files.
I know comments are not allowed in json, but they are convinient for letting others/your future you, know whats going on without digging in source too much... especially in config files.
Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. - Douglas Crockford, 2012
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.