Giter Site home page Giter Site logo

exports-loader's People

Contributors

alexander-akait avatar amareshsm avatar anshumanv avatar buffcode avatar cap-bernardito avatar commanderroot avatar dependabot[bot] avatar ersachin3112 avatar evilebottnawi avatar flakyfilibuster avatar glinkis avatar jhnns avatar joshwiens avatar kevinzwhuang avatar michael-ciniawsky avatar pixnbits avatar ryantd avatar shama avatar shellscape avatar simon04 avatar skleeschulte avatar snitin315 avatar sokra avatar spacek33z avatar ysangkok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exports-loader's Issues

I don't understand the documentation

Please give more example of how to use this. For instance an example showing exactly where those require lines mentioned go. A full file using this would be nice. .

require("exports-loader?file,parse=helpers.parse!./file.js");
// adds below code the the file's source:
// exports["file"] = file;
// exports["parse"] = helpers.parse;

require("exports-loader?file!./file.js");
// adds below code the the file's source:
// module.exports = file;

In what files is this needed?

webpack-defaults upgrade

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

Cannot use with expose loader. Invalid options error even though options are valid.

  • Operating System: MacOS Catalina 10.15.5
  • Node Version: 12.18.2
  • NPM Version: 6.14.5
  • webpack Version: 4.43.0
  • webpack-cli version: 3.3.12
  • exports-loader Version: 1.1.0

Expected Behavior

I expected a valid build and export of the module.

Actual Behavior

Validation Error:

ValidationError: Invalid options object. Exports Loader has been initialized using an options object that does not match the API schema.
 - options misses the property 'exports'. Should be:
   non-empty string | object { name, syntax?, alias? } | [non-empty string | object { name, syntax?, alias? }, ...] (should not have fewer than 1 item)

It is clear I have the options in the config.

Code

{
...
  module: {
    rules: [
      {
        test: path.resolve(__dirname, 'assets/public/js/templates.js'),
        use: [
          {
             loader: 'expose-loader',
             options: {
               exposes: 'templates'
             }
           },
          {
            loader: 'exports-loader',
            options: {
              type: 'commonjs',
              exports: 'single templates'
            }
          },
        ]
      }
    ]
  }
...
}

templates.js is a file with a single variable templates. I want webpack to add the exports code module.exports = templates; then expose that variable to the global scope so I can access window.templates.

How Do We Reproduce?

Simply use expose loader with exports loader.

Also note that exports loader works as expected when used by itself without expose-loader.

How can I export only one variable ?

This issue is for a:

  • [x ] bug
  • feature request
  • modification request

Code

Consider code stated here.

At webpack.config.jsI use following line : use: 'exports-loader?file'

I am trying to receive content of file constant in index.js:

import { file } from './globals.js';
console.log(file);

Result undefined, but content of file expected.

But ,if :
use: 'exports-loader?file,parse=helpers.parse'

import { file, parse } from './globals.js';
console.log(file, parse);

Results as expected.

Is this bug or how can I get only one variable please ?

Thanks.

Get 'Uncaught ReferenceError: exports is not defined' when using in webpack 4.6.0

  • Operating System: MacOS 10.13.3
  • Node Version: 10.0.0
  • NPM Version: 5.6.0
  • webpack Version: 4.6.0
  • exports-loader Version: 0.7.0

This issue is for a:

  • bug
  • feature request
  • modification request

Code

webpack.config.js
  module: {
       rules: [{
          test: '/\.js$/',
          loader: 'exports-loader'
       }]
  }
  let main = new Vue();
  export default main;
  exports['main'] = main;  // this statement comes an error called "Uncaught ReferenceError: exports is not defined"

Expected Behavior

'main' can be a global variable in the html.

Actual Behavior

An error occurs when executing ' exports['main'] = main; ',
image

How Do We Reproduce?

Set webpack's module like the above shows.

Combining interpolation with renaming

Using name interpolation while also renaming the export, as in a query like

import {foo} from 'exports-loader?[name]=global!./foo.js';

does not seem to work. It adds

exports.foo = foo;

to foo.js, instead of

exports.foo = global;

This seems to happen because the loader first does interpolation on the keys of the query object, and then later uses these interpolated strings to look up the names of the globals that are to be exported.


  • Operating System: Arch Linux on x86_64 (Kernel version 5.1.15-arch1-1-ARCH)
  • Node Version: 11.15.0
  • NPM Version: 6.9.0
  • webpack Version: 4.35.0
  • exports-loader Version: 0.7.0

This issue is for a:

  • bug
  • feature request
  • modification request

Code

CLI Command
  $ npx webpack
  $ node dist/main.js
Further code

See this gist.

Expected Behavior

The example should print 42.

Actual Behavior

It fails with a ReferenceError for foo, which it is accessing as a global when trying to export it from foo.js.

How Do We Reproduce?

Just clone the above gist and run the given commands.

No same alternative for previous usage `exports-loader?exports.toString()`

  • Operating System: macOS 10.15
  • Node Version: v12.18.2
  • NPM Version: 6.14.5
  • webpack Version: 4.43.0
  • exports-loader Version: 1.1.0

Feature Proposal

`exports-loader?type=commonjs&exports=exports.toString()``

Or how can I reference the unknown exported token in loader query?

Feature Use Case

Don't break previous usage of this loader.

this.getOptions is not a function

Getting the following error:

Module build failed (from ./node_modules/exports-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
at Object.loader (/home/ssoloski/talon-ng/talon/node_modules/exports-loader/dist/index.js:23:24)
@ ./app/javascript/packs/application.js 10:0-42

Export raw code as default

  • webpack Version: 3

Lets assume you have a basic js file which has no exports or any functions:

object-assign-detect.js

'assign' in Object

It would be great if you can wrap this in a default export (along with a return)

export default function() {
   return 'assign' in Object
}

Usage

import objectAssignDetect from 'exports-loader?....'

if (objectAssignDetect()) {
  ...
}

Support for file name token?

It would be very useful if there was a way to have the file name as a token when setting up a config for loading multiple modules under the same global namespace.
Example: exports-loader?NAMESPACE.[name]

For a real-world example, I'm using the three example modules, who all rely on and attach to the global THREE namespace.

So a config for loading them could look like this:

{
    test: /three\/examples\/js/,
    use: ["imports-loader?THREE=three", "exports-loader?THREE.[name]"]
}
alias: {
    "three-examples": path.join(__dirname, "./node_modules/three/examples/js")
},

And I could load them like this:

import ColladaLoader from "three-examples/loaders/ColladaLoader";
import XLoader from "three-examples/loaders/XLoader";

loader does not export the module

I use the lib js-aruco which is browser only. Thats why I try to shim that lib. I do it this way:

module.exports = require('exports-loader?CV!../js-aruco/src/cv.js')

In the bundle I can see the libraray included - but the module.exports = CV is missing.
However - a similar case is working:

module.exports = require('imports-loader?CV=./cv.js!exports-loader?AR!../js-aruco/src/aruco.js')

Here I can see the export. Ofc this code fails because it requires CV do be loaded correctly which is not the case.

I am using webpack v3

// EDIT: When requireing the module directly from my app require('./modules/cv.js') it exports the module. However cv still cant see ar because its put twice in the bundle. One time with export and one time without.

It looks like the export loader is simply not executed

Becomes incompatible with es6-promise

  • Operating System: MacOs
  • Node Version: 13+
  • NPM Version: 6.14.4
  • webpack Version: 4.42.1
  • exports-loader Version: 1.0.0+

Expected Behavior

webpack: compiled successfully message.

Actual Behavior

webpack: es6-promise throws an error. attached the screenshot.

Code

// webpack.config.js
// If your code blocks are over 20 lines, please paste a link to a gist
// (https://gist.github.com).

import "whatwg-fetch";

// additional code, HEY YO remove this block if you don't need it

How Do We Reproduce?

use webpack with the next modules:
"whatwg-fetch": "latest"
"es6-promise": "^4.2.8",
"es6-promise-loader": "^1.0.2",
"exports-loader": "1.0.0",

the issue comes up when any "fetch" related module imported, if export-loader v1.0.0+ installed. there have been no issues with previous ones.

Screen Shot 2020-07-27 at 03 41 29

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.