define wrapper blocks webpack2
See original GitHub issueThe current define wrapper in JSONIX blocks usage in webpack2, I wonder if it’s time to get rid of this?
/*if (typeof define !== 'function') {^M
// Load the define function via amdefine^M
var define = require('amdefine')(module);^M
// If we're not in browser^M
if (typeof window === 'undefined')^M
{^M
// Require xmldom, xmlhttprequest and fs^M
define(["xmldom", "xmlhttprequest", "fs"], _jsonix_factory);^M
}^M
else^M
{^M
// We're probably in browser, maybe browserify^M
// Do not require xmldom, xmlhttprequest as they'r provided by the browser^M
// Do not require fs since file system is not available anyway^M
define([], _jsonix_factory);^M
}^M
}^M
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Configure webpack using functional feature blocks. - GitHub
defineConstants () is a small convenience wrapper around webpack's DefinePlugin. It is composable and automatically encodes the values. Use it to replace ...
Read more >@webpack-blocks/webpack2 NPM | npm.io
This is the webpack2 block providing webpack 2 core functionality. Also provides all @webpack-blocks/core exports for convenience.
Read more >Use webpack or node.js compiler to wrap all functions and ...
It will manipulate your code before it is bundled by webpack. It may be easier just to inject whatever you want your 'wrapper'...
Read more >@webpack-blocks/webpack | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Dependency Management - webpack
A context module is generated. It contains references to all modules in that directory that can be required with a request matching the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, I could get a workaround for webpack as follows:
Install
imports-loader
andexports-loader
and add the following rule towebpack.config.js
:You can then import
Jsonix
like so:The webpack-rule does the following:
jsonix
is loadedjsonix
module it setsrequire
to false (sojsonix
thinks it runs in the browser)Jsonix
, so that it can be used in ES6import
statements@highsource the code that checks in which context Jsonix is running should also check for the ES6
import
statement, which is the mostly used way to import modules in webpack. So it would happily run with webpack as well as with native ES6 imports. Thanks for that great library 😃On new versions of imports/exports-loader (I’m using v1.1.0) the equivalent syntax is: