Giter VIP home page Giter VIP logo

script-loader's Introduction

npm node deps chat

! NO LONGER MAINTAINED !

This module is deprecated and will no longer be maintained.

It has a known issue of generating non-deterministic hashes (see #49, #56, #60). Do not use it.

In most cases, you can replace the functionality by using raw-loader instead:

- import('script-loader!someScript.js')
+ import('raw-loader!someScript.js').then(rawModule => eval.call(null, rawModule.default))

If you need some transformations to be applied to the script you want to load, you may need to find or write yourself a separate loader for that. Some documentation that might be helpful:


Script Loader

Install

npm install --save-dev script-loader

Usage

Executes JS script once in global context.

⚠️ Doesn't work in NodeJS

Config (recommended)

import './script.exec.js';

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.exec\.js$/,
        use: [ 'script-loader' ]
      }
    ]
  }
}

Inline

import 'script-loader!./script.js';

Options

Name Type Default Description
sourceMap {Boolean} false Enable/Disable Sourcemaps
useStrict {Boolean} true Enable/Disable useStrict

sourceMap

Type: Boolean Default: false

To include source maps set the sourceMap option.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.script\.js$/,
        use: [
          {
            loader: 'script-loader',
            options: {
              sourceMap: true,
            },
          },
        ]
      }
    ]
  }
}

useStrict

Type: Boolean Default: true

To disable use strict set the useStrict option to false.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.script\.js$/,
        use: [
          {
            loader: 'script-loader',
            options: {
              useStrict: false,
            },
          },
        ]
      }
    ]
  }
}

Maintainers


Juho Vepsäläinen

Joshua Wiens

Kees Kluskens

Sean Larkin

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.